Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Floating div top spacing

Tags:

html

jquery

css

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>  
like image 582
Frank Avatar asked Nov 24 '25 01:11

Frank


1 Answers

use float property

.col2 {
float: right;
height: 200px;
}

and set

.col3{border: 1px solid red;
float: left;
}

Demo: fiddle

like image 189
Selvamani Avatar answered Nov 25 '25 15:11

Selvamani