css - Ordering divs with javascript -
i have this: http://s9.postimg.org/wwizuwnq7/untitled_1.png
and if see, divs (where marked in green) have space of pixel. , want if there 0-20 pixel space between divs, order them this: http://s23.postimg.org/ky2htcpt7/image.png
so, started on javascript , dont know to continue..
var position = new array(); $(".post").each(function(){ position[$(this).attr("id")] = $(this).offset().top - $(window).scrolltop(); }); now have position of divs, , need check divs have space of 0 - 20 pixel, , want take down higher block.
i not sure if way, , if now, need idea..
thanks!
you can adding container div around bottom 2 blocks. way in line, regardless of height of either of top 2 blocks. should try not use javascript styling. css powerful.
here's fiddle: http://jsfiddle.net/kvn7x/
html:
<div> <div style='height:100px;'></div> <div style='height:200px;'></div> </div> <div style='clear:left'> <div style='height:80px;'></div> <div style='height:80px;'></div> </div> css:
div div{background:red; width:150px; display:inline-block; margin:5px; float:left; clear:none}
Comments
Post a Comment