css - Stack html divs with different width and height? -


what best way stack multiple divs without generating space in between?

i'm using css float different height , width achieve current outcome:

*{margin:0;padding:0;}  #main{   background: blue;   max-width:1000px;   margin:0 auto;   overflow:hidden;   text-align:center; }  div>div{   background: green;   width:33.33333%;   float:left;   border:1px solid grey;   padding:5px;   box-sizing:border-box;   height:100%;  }  div>div>div{   width:100%;   background:yellow;   height:100%; } 

http://codepen.io/vincentccw/pen/wvexkb

as can see outcome isn't intended achieve, blue spacing in between , horizontal line breaks......

enter image description here

what want have divs arrange them-self automatically , take whatever blue space there left occupy....

you take @ flexbox: https://css-tricks.com/snippets/css/a-guide-to-flexbox/

also hashem pointed out, css solution: http://demosthenes.info/blog/844/easy-masonry-layout-with-flexbox


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -