Reputation: 1373
I want to align a few even number of inline blocks as below:
_____ _____ _____ _____
| | | | | | | |
| 1 | | 2 | | 3 | | 4 |
|_____| |_____| |_____| |_____|
_____ _____
| | | |
| 5 | | 6 |
|_____| |_____|
The problem is: when there is extra content in any of the blocks, the boxes are misaligned. Please check the below link:
How can i resolve this?
Upvotes: 1
Views: 8710
Reputation: 618
I would recommend using absolute positioning to break your .entry divs free from the document flow.
.entry
{
display:inline-block;
margin-top:10px;
width:100px;
height:100px;
border:1px solid red;
position:relative;
}
.entry span
{
position: absolute;
top:40%;
left:0;
width:100%;
text-align:center;
}
Upvotes: 0
Reputation: 172458
Try this:
.entry
{
display:inline-block;
margin-top:10px;
width:100px;
height:60px;
padding-top:40px;
border:1px solid red;
vertical-align: top;
}
Upvotes: 0
Reputation: 1168
use vertical-align: top;
for inline-block elements - http://jsfiddle.net/5JSAG/49/
Upvotes: 1
Reputation: 41832
Add vertical-align: top
to your css code.
.entry
{
display:inline-block;
margin-top:10px;
width:100px;
height:60px;
padding-top:40px;
border:1px solid red;
vertical-align: top; /* added */
}
Upvotes: 12