jquery - Isotope issue with css :nth-child(3n+2) -


i used isotope js sorting bootstrap item. faced problem, when sorting. used

.col-md-4:nth-child(3n+2) {     border-left: 1px solid #ccc;     border-right: 1px solid #ccc; } 

when sort isotope, css applied 3n+2 position change.(because isotope put css position absolute). want border left , right 2 item in each row when sorting , in normal. guide me solve this.

in jsfiddle: http://jsfiddle.net/tamilcselvan/v0k608x1/

$(function () {      $container = $('.row');      $container.isotope({          itemselector: '.col-md-4',          layoutmode: 'fitrows',          getsortdata: {              name: '.name'          }      });        $('button').click(function () {          $container.isotope({              sortby: 'name'          });      });    });
.col-md-4:nth-child(3n+2) {      border-left: 1px solid #ccc;      border-right: 1px solid #ccc;  }  .col-md-4:nth-child(3n+1) {      padding-left: 0;  }  .col-md-4:nth-child(3n+3) {      padding-right: 0;  }  .col-md-4 {      text-align:center;      margin: 0 0 1em 0;  }
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>    <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.isotope/2.2.0/isotope.pkgd.min.js"></script>    <button>name</button>  <div class="container">      <div class="row">          <div class="col-md-4">               <h2 class="name">q</h2>            </div>          <div class="col-md-4">               <h2 class="name">w</h2>            </div>          <div class="col-md-4">               <h2 class="name">e</h2>            </div>          <div class="col-md-4">               <h2 class="name">r</h2>            </div>          <div class="col-md-4">               <h2 class="name">t</h2>            </div>          <div class="col-md-4">               <h2 class="name">y</h2>            </div>          <div class="col-md-4">               <h2 class="name">u</h2>            </div>          <div class="col-md-4">               <h2 class="name">i</h2>            </div>          <div class="col-md-4">               <h2 class="name">o</h2>            </div>          <div class="col-md-4">               <h2 class="name">p</h2>            </div>          <div class="col-md-4">               <h2 class="name">a</h2>            </div>          <div class="col-md-4">               <h2 class="name">s</h2>            </div>          <div class="col-md-4">               <h2 class="name">d</h2>            </div>      </div>  </div>

(note: please view run code snippet in full screen).

so might seem little "hacky" accomplish trying do.

https://jsfiddle.net/v0k608x1/4/

$(function () {      $container = $('.row');     $container.isotope({         itemselector: '.span4',         layoutmode: 'fitrows',         getsortdata: {             name: '.name'         }     });     // add function re-apply after sorted     $container.isotope( 'on', 'arrangecomplete', function( filtereditems ) {         (i = 0; < filtereditems.length; i++) {             // replicates :nth-child(3n+1)             var css3n1 = (3*i)+1;             if (filtereditems[css3n1] !== undefined) {                 $(filtereditems[css3n1].element).css({                     'border-left': '1px solid #ccc',                     'border-right': '1px solid #ccc',                 });             } else {                 break;             }         }     });      $('button').click(function () {         // clear styling before sorting can re-applied         $('.span4').css({             'border-left': 'none',             'border-right': 'none',         });         $container.isotope({             sortby: 'name'         });     });  }); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -