jquery - How to access single column which created with css3 columns? -


i have div.masonry items.

<div class="masonry">     <div class="item">some text<div>     <div class="item">some text<div>     <div class="item">some text<div>  ... </div> 

i styled div using css3 columns.

.masonry { -moz-column-count: 5;  } 

and items correctly divided in 5 columns.

now want access items , style them column number. example first column items become blue, second red , , on....

and want jquery.

help me.

sorry previous answer based on misunderstanding of columns. try this:

var numcol = $('.masonry').css('column-count'); var numelem = $('.masonry .item1').length; var elempercol = numelem / numcol;  for( var = 0; < numcol; i++){     for(var j = 0; j < elempercol; j++){         if(i==0){             $('.masonry .item1').eq(j+(i*elempercol)).css('color', 'red');                         }         else if(i==1){             $('.masonry .item1').eq(j+(i*elempercol)).css('color', 'blue');             }         else if(i==2){             $('.masonry .item1').eq(j+(i*elempercol)).css('color', 'green');             }         else if(i==3){             $('.masonry .item1').eq(j+(i*elempercol)).css('color', 'purple');             }         else if(i==4){             $('.masonry .item1').eq(j+(i*elempercol)).css('color', 'black');             }     } } 

it break if don't have equal number of elements per column though.

http://jsfiddle.net/dk2g41qm/7/


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -