I've run into some layout overlap issues with a css float
container recently, and had started looking at using display: inline-block
instead. So far, so good... except I need to be able to add line-breaks, as clear
does for floats. Some sample text...
.ib {
border: 1px solid #333;
display: inline-block;
padding: 3px;
}
.block-start {
border: 1px solid #0cc;
display: inline-block;
padding: 3px;
}
<div class="container">
<div class="block-start">block-start</div>
<div class="ib">inline-block</div>
<div class="ib">inline-block</div>
<div class="ib">inline-block</div>
<div class="ib">inline-block</div>
<div class="block-start">block-start</div>
<div class="ib">inline-block</div>
<div class="ib">inline-block</div>
<div class="ib">inline-block</div>
<div class="ib">inline-block</div>
</div>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…