I should align the fixed width divs.
I have a container with a fixed width
I have dynamic divs inside but they also have a fixed width.
I would like to put 4 divs per line.
So I used CSS's float
rule
My actual problem is that when the last div (card) on the line has a short height the next card gets under it.
What I'm expecting is the next div get back to a complete line.
.card {
width:200px;
height:200px;
border: 1px solid black;
float: left;
}
.container {
width: 900px;
}
.shortcard {
height:50px
}
<div class="container">
<div class="card">
</div>
<div class="card">
</div>
<div class="card">
</div>
<div class="card shortcard">
</div>
<div class="card">
It should be in next line
</div>
<div class="card">
</div>
</div>
When the height is longer, the element is getting to another line
.card {
width:200px;
height:200px;
border: 1px solid black;
float: left;
}
.container {
width: 900px;
}
.shortcard {
height:50px
}
<div class="container">
<div class="card">
</div>
<div class="card">
</div>
<div class="card">
</div>
<div class="card ">
</div>
<div class="card">
I'm ok here
</div>
<div class="card">
</div>
</div>