M
M
maksim20992015-09-01 18:08:32
HTML
maksim2099, 2015-09-01 18:08:32

How to make friends bootstrap grid and Masonry.js?

Good day, please tell me when creating a col-md-4 col-md-8 grid and applying Masonry to it, it works well. But as soon as we add {gutter:10} padding, the grid floats, i.e. the div is moved to the next line.

<div class="container">
        <div class="row">
    <div class="masonry-container">
          <div class="col-md-4 item"><img src="img/1.jpg" alt="alt"></div>
          <div class="col-md-8 item "><img src="img/3.jpg" alt="alt"></div>
          <div class="col-md-4 item "><img src="img/1.jpg" alt="alt"></div>					
          
        </div>
      </div>
    </div>

.item {
  height: 250px;
}

.item img {
  width: 100%;
  transition: transform 2s;
}

var $container=$(".masonry-container");
$container.imagesLoaded(function(){
  $container.masonry({
    itemSelector:".item",
    columnWidth: ".item", 
                gutter:10
               


  })
});
$('.item').imagefill()

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nazar Mokrinsky, 2015-09-01
@nazarpc

Add padding (with box-sizing: border-box, of course)

M
maksim2099, 2015-09-01
@maksim2099

Thanks, but the problem is that during the animation, the Padding part is filled with the image and doesn't scale well. Can you suggest what else can be done in my case?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question