css - Why does inline-block "steal" 4px when float's doesn't -
i have simple page should render outer container of 1220px width 2 inner sections, 1 770px wide , 1 330px wide. have both 20px margin , 770px have padding set 20px on left , right.
this makes
- 20+20+770+20+20+20+330+20 = 1220
- or ... margin + padding + section + padding + margin + margin + section + margin
when using float can have outer width set 1220px , inner widths set 770 , 330 using margin , padding fill rest. renders correct don't want floats!
<div style="width: 1220px; background-color:#ffe4c4;"> <section style="width: 770px; float: left; padding: 0 20px; margin: 20px; background-color: #ccc;"> <!-- content goes here --> @renderbody() </section> <section style="width: 330px; float: left; margin: 20px; background-color: #d8bfd8; padding: 0"> <img src="/media/1155/menu_fake.jpg" width="330" /> </section> </div>
when using inline-block, have remove pixels (4px exact) make elements display next each other.
<div style="width: 1220px; background-color:#ffe4c4;"> <section style="width: 766px; vertical-align:top; padding: 0 20px; margin: 20px; background-color: #ccc;"> <!-- content goes here --> @renderbody() </section> <section style="width: 330px; display: inline-block; vertical-align:top; margin: 20px; background-color: #d8bfd8; padding: 0"> <img src="/media/1155/menu_fake.jpg" width="330" /> </section> </div>
any advice appreciated, thanks!
inline-block
elements render white-space between elements in source. eliminate them, need remove white-spaces in code.
more details here
Comments
Post a Comment