Why does .ibg .im
margin setting effect the text alignment?
I've tried finding a solution to this but the vagueness of the search terms aren't bringing up results in Google.
Can anyone shed light on this? Any assistance appreciated.
Fiddle here: http://jsfiddle.net/775zA/1/
To see my issue, remove the margin from the .ibg .im
CSS rule.
CSS
body {
padding-top: 50px;
}
.ibg {
width: 48px;
height: 48px;
display: inline-block;
}
.ibg .im {
margin: 8px;
}
.olist {
font-size: 18px;
font-weight: bold;
font-family: Futura, "Trebuchet MS", Arial, sans-serif;
list-style: none;
}
.olist li {
list-style: none;
}
.olist .lbl {
margin-left: 10px;
display: inline-block;
}
HTML
<div class="container">
<div class="starter-template">
<ul class='olist'>
<li>
<div class='ibg' style='background-color: #B1BF54'>
<div class='im'>
<img src='http://placehold.it/32x32/000000/ffffff&text=img' />
</div>
</div>
<div class='lbl'>Title here</div>
</li>
</ul>
</div>
</div><!-- /.container -->
UPDATE
So it seems that this question touches on this subject: CSS Margin Collapsing. However it does not address a way to remove the sibling padding/margin.
Say I wanted to to have text occur in line with the top of the green box... is there no way to do this without position:relative;
and top:-8px
? That solution seems unnecessarily hackish response to a very strange CSS quirk