css - How to position divs next to each other and under each other? -



css - How to position divs next to each other and under each other? -

this stupid question , it's easy solve, having problem doing so. question is, how position 2 lastly sections (shown in picture) below first ones?

http://imageshack.us/photo/my-images/829/63128947.jpg/

this code:

#main_div{ display: -webkit-box; -webkit-box-orient: horizontal; border: 1px solid black; max-width: 1000px; } #main_section{ width: 600px; height: 450px; border: 1px solid black; padding: 5px; margin: 10px; } #sub_section1{ width: 100px; height: 200px; border: 1px solid black; padding: 5px; margin: 10px; -webkit-box-flex: 1; } #sub_section2{ width: 100px; height: 200px; border: 1px solid black; padding: 5px; margin: 10px; -webkit-box-flex: 1; } #sub_section3{ width: 100px; height: 200px; border: 1px solid black; padding: 5px; margin: 10px; -webkit-box-flex: 1; } #sub_section4{ width: 100px; height: 200px; border: 1px solid black; padding: 5px; margin: 10px; -webkit-box-flex: 1; }

here's fiddle demonstrates 1 way it. added div element (i called "sidebar"), , set smaller divs within of it. each element floated, , width of sidebar container wide plenty contain these elements. may need resize viewport in fiddle things flow have them in screenshot.

since smaller div elements styled same, opted utilize class instead of multiple id's. way aren't duplicating rules unnecessarily in css.

also note achieved absolute positioning, if you're kind of thing. there multiple ways of doing things in css.

css html5 html positioning

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -