html - CSS float divs left to right underneath each other -


i want float divs left right underneath each other sort of this:

1    2 3     4 

but is:

1  2 3  4 

does know how properly? thanks

make wrapper div , let inner divs touch each other fragment:

html:

<div>     <div>1</div>     <div>2</div>     <div>3</div>     <div>4</div>     <div>5</div>     <div>6</div> </div> 

css:

body > div {     background: lightgreen;     width: 99px;     overflow: auto; } div > div {     width: 50px;     height: 50px; } div > div:nth-child(2n-1) {     background: lightyellow;     float: left; } div > div:nth-child(2n) {     background: lightblue;     float: right; } 

and demo


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -