I would like to align the red columns under the black columns without changing the HTML:
http://jsfiddle.net/3HUNz/28/
Are there any jquery or css solutions for this?
CSS:
.col{
width: 25%;
border: 1px solid black;
margin: 10px;
padding:2px;
float:left;
}
.clear{clear:both;}
.col1{height: 200px;}
.col2{height: 300px;}
.col3{height: 200px;}
.col4{height: 200px; border: 1px solid red;}
.col5{height: 220px; border: 1px solid red;}
.col6{height: 120px; border: 1px solid red;}
HTML:
<div class="col col1">1</div>
<div class="col col2">2</div>
<div class="col col3">3</div>
<div class="clear"></div>
<div class="col col4">4</div>
<div class="col col5">5</div>
<div class="col col6">6</div>
use float property
.col2 {
float: right;
height: 200px;
}
and set
.col3{border: 1px solid red;
float: left;
}
Demo: fiddle
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