javascript - Mansory/Isotope not working with elements of different widths -


as can see in code-pen below; there's space right next first image not being filled, when there's other elements can put there.

i haven't found solution had elements width defined in percentage.

codepen: https://codepen.io/anon/pen/qxemaz

html:

<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgfzhoseeamdoygbf13fyquitwlaqgxvsngt4=" crossorigin="anonymous"></script>  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-tc5iqib027qvyjsmfhjomalkfuwvxzxupncja7l2mcwnipg9mgcd8wgnicpd7txa" crossorigin="anonymous"></script>  <script src="https://unpkg.com/imagesloaded@4/imagesloaded.pkgd.min.js"></script>      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-bvyiisifek1dgmjrakycuhahrg32omucww7on3rydg4va+pmstsz/k68vbdejh4u" crossorigin="anonymous">      <script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.min.js"></script> <div class ="container"> <div class=" isotope row  gutter">                     <div class="grid-sizer col-2 mosaic-item">                           <img class="img-responsive" src="http://via.placeholder.com/150x350"></img>                        </div>                      <div class="col-1 mosaic-item ">                         <img class="img-responsive" src="http://via.placeholder.com/150x350"></img>                     </div>                     <div class="col-2 mosaic-item ">                         <img class="img-responsive" src="http://via.placeholder.com/350x150"></img>                     </div>                     <div class="col-2 mosaic-item ">                         <img class="img-responsive" src="http://via.placeholder.com/150x350"></img>                     </div>                      <div class="col-2 mosaic-item ">                         <img class="img-responsive" src="http://via.placeholder.com/350x150"></img>                     </div>                      <div class="col-2 mosaic-item ">                         <img class="img-responsive" src="http://via.placeholder.com/150x350"></img>                     </div>          </div> </div> 

css:

.col-1 , .col-1 {     width: 100%; }  .col-2 , .col-2 {     width: 49.99%; }  @media screen , (max-width: 992px) {     .col-2 ,     .col-2 {         width: 50%;     } }  @media screen , (max-width: 767px) {     .col-2 ,     .col-2 {         width: 100%;     } }  .col-1 , .col-2{     float: left; } .gutter>div{   padding: 10px; }  .gutter img{   width: 100%; }   

javascript/jquery:

 $(document).ready(function(){    isotope();  }); function isotope(){ var $portfolio = $('.isotope');        $portfolio.imagesloaded(function() {            $portfolio.isotope({                isoriginleft: true,                stagger: 30,                masonry: {                  percentposition: true                }            });            $portfolio.isotope();         }); } 

enter image description here

thank you.

is after? did add in 2 column block after first one. check code in full screen mode see columns work.

 $(document).ready(function(){     isotope();   });  function isotope(){  var $portfolio = $('.isotope');         $portfolio.imagesloaded(function() {             $portfolio.isotope({                 isoriginleft: true,                 stagger: 30,                 masonry: {                   percentposition: true                 }             });             $portfolio.isotope();           });  }       
.col-1 ,  .col-1 {      width: 100%;  }    .col-2 ,  .col-2 {      width: 49.99%;  }    @media screen , (max-width: 992px) {      .col-2 ,      .col-2 {          width: 50%;      }  }    @media screen , (max-width: 767px) {      .col-2 ,      .col-2 {          width: 100%;      }  }    .col-1 ,  .col-2{      float: left;  }  .gutter>div{    padding: 10px;  }    .gutter img{    width: 100%;  }
         <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgfzhoseeamdoygbf13fyquitwlaqgxvsngt4=" crossorigin="anonymous"></script>    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-tc5iqib027qvyjsmfhjomalkfuwvxzxupncja7l2mcwnipg9mgcd8wgnicpd7txa" crossorigin="anonymous"></script>    <script src="https://unpkg.com/imagesloaded@4/imagesloaded.pkgd.min.js"></script>  	 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-bvyiisifek1dgmjrakycuhahrg32omucww7on3rydg4va+pmstsz/k68vbdejh4u" crossorigin="anonymous">        <script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.min.js"></script>  <div class ="container">  <div class=" isotope row  gutter">                      <div class="grid-sizer col-2 mosaic-item">                            <img class="img-responsive" src="http://via.placeholder.com/150x350"></img>                                              </div>                     <div class="grid-sizer col-2 mosaic-item">                            <img class="img-responsive" src="http://via.placeholder.com/150x350"></img>                                              </div>                        <div class="col-1 mosaic-item ">                          <img class="img-responsive" src="http://via.placeholder.com/150x350"></img>                      </div>                      <div class="col-2 mosaic-item ">                          <img class="img-responsive" src="http://via.placeholder.com/350x150"></img>                      </div>   <div class="col-2 mosaic-item ">                          <img class="img-responsive" src="http://via.placeholder.com/150x350"></img>                      </div>                                          <div class="col-2 mosaic-item ">                          <img class="img-responsive" src="http://via.placeholder.com/350x150"></img>                      </div>                        <div class="col-2 mosaic-item ">                          <img class="img-responsive" src="http://via.placeholder.com/150x350"></img>                      </div>            </div>  </div>


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -