Reputation: 79
Can anyone help me to understand this please?
You can see the example here:
HTML:
<div class="rt-block">
<div>
<div>
<div class="itemContainer">
<span>Lorem ipsum dolor sit amet</span>
</div>
<div class="clr"></div>
</div>
<div class="k2Pagination">
</div>
</div>
</div>
CSS:
.rt-block {
margin: 10px;
padding: 15px;
position:relative;
}
.itemContainer {float:left;}
.k2Pagination {
margin: 24px 0 4px;
}
.clr {
border: medium none;
clear: both;
display: block;
float: none;
height: 0;
line-height: 0;
margin: 0;
padding: 0;
}
In Firefox, there is a gap between the "itemContainer" and the surrounding "rt-block". Other browsers don't have this.
It is fixed by two things: removing the float:left on itemContainer, and also by removing the margin on k2 pagination. I'd prefer not to do either of these things if possible.
Thanks for any help
Upvotes: 2
Views: 1696
Reputation: 14681
First, this is the display as I see it in Firefox:
I think you have one too many <div>
. When viewing on firefox the extra padding is added on the first <div>
after <div class="rt-block">
. My guess is that it produces a line break that causes the float to float under the line, it seems to be confirmed by the fact that adding line-height: 0
to this div fixes the problem.
You can remove the extra <div>
:
<div class="rt-block">
<div>
<div class="itemContainer">
<span>Lorem ipsum dolor sit amet</span>
</div>
<div class="clr"></div>
</div>
<div class="k2Pagination">
</div>
</div>
Or you can set the line height to 0 for the first div:
.rt-block > div {
line-height: 0;
}
Or better, make it inline-block:
.rt-block > div {
display: inline-block;
}
Upvotes: 3
Reputation: 43
I have no idea what is the reason for that extra spacing in Firefox but you can give padding instead of margin.
.k2Pagination {
padding: 24px 0 4px;}
This is simple and it might work.
Upvotes: 0