I have several div (class="badge"
) to display in the vertical. Not sure why I got extra space between 2 div in FF and IE (Chrome works fine).
I need them to display either no space or equal space in all browsers.
http://jsfiddle.net/2hxak/1/
HTML:
<div class="stat-badges">
<div class="badge">
<div class="stat-num">123456</div>
</div>
<div class="badge">
<div class="stat-num">0</div>
</div>
</div>
CSS:
.stat-badges {
text-align: center;
width: 55px;
}
.badge {
display: inline-block;
padding: 2px 4px;
color: #ffffff;
vertical-align: baseline;
white-space: nowrap;
background-color: #999999;
}
.badge .stat-num {
max-width: 30px;
min-width: 20px;
padding: 3px 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
The space will disappear if I remove overflow: hidden;
. I keep overflow: hidden
with ellipse
to crop long text.
Change vertical-align: baseline;
to vertical-align: top;
in your badge class rule.
jsFiddle example
display: inline-block;
is messing this up. Use float: left;
instead (possibly with clear: left;
to make sure every badge is on a new line). (jsFiddle)
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