css - 2-column design with main content containing boxes that I need to align in a 2 column layout -


here's example of code:

http://jsfiddle.net/9ecke/1/

html

<div class="wrapper">     <div class="sidebar">         <ul>             <li>                 test             </li>             <li>                 test             </li>             <li>                 test             </li>         </ul>     </div>     <div class="content">         <div class="box one">box 1</div>         <div class="box two">box 2</div>         <div class="box three">box 3</div>     </div> </div> 

css

.box{float:left; padding:20px; border:1px solid red;} .three{clear:left;} .sidebar{float:left;} 

i have tried adding float:left .content{} however, works when screen wide, mobile displays full content area ends going below sidebar. if try using span7 (bootstrap, width: 58%), doesn't work wide screen.

is there way can set arrangement without needing set width?

the problem having float due height of first left float. there enough height on left float prevent box 1 , 2 falling below not box 3. there 2 ways prevent this. can add artificial height .sidebar height: 300px; or that. or can use more common practice , use left , right floats. .sidebar float: left; , .content float: right;. if choose go different floats should declare width each .sidebar have width: 30%; , .content have width: 70%;. can play around percentages widths there format page style. if use borders have change percentages accommodate them.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -