Why is the blue div not adjacent to green div?
This is the html. Nothing but containers with borders.
<div id="wrapper960" style="min-height:350px; border:1px red solid">
<div class="content-sidebar-l" style="min-height:250px; border:1px yellow solid"> </div>
<div class="content" style="min-height:250px; border:1px green solid"></div>
<div class="content-sidebar-r"style="min-height:250px; border:1px blue solid"></div>
</div>
This is the CSS with centered div on the middle.
#wrapper960 {margin:0 auto; padding:0; width:960px;}
.content-sidebar-l {
float: left;
width:170px;
margin:0;
padding:0;}
.content {
margin:0 auto;
padding:1em 0 0 0;
width:610px;
background-color:#fff;}
.content-sidebar-r {
float: right;
width:160px;
margin:0;
padding:0;}
(source: imagesup.net)
Here it is in a JSFiddle
Re-order your HTML to:
<div id="wrapper960" style="min-height:350px; border:1px red solid">
<div class="content-sidebar-r"style="min-height:250px; border:1px black solid"></div>
<div class="content-sidebar-l" style="min-height:250px; border:1px yellow solid"> </div>
<div class="content" style="min-height:250px; border:1px green solid"></div>
</div>
jsFiddle example
You need to float your sidebar to the right first, otherwise by placing it last it can't float up above an element before it that is also floated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With