Vertical alignment of empty inline-block elements

ぃ、小莉子 提交于 2019-11-29 10:28:15

Give the span top alignment then negative margin equal to your padding, and you don't need the non-breaking space hack.

span
{
    display:inline-block;
    width:5em;
    height:5em;
    padding:1em;
    vertical-align:top;
    margin-top: -1em;
}



a
    <span style="background-color:blue;">b</span>
    <span style="background-color:green;"></span>
    <span style="background-color:red;">c</span>
d
a
<span style="background-color:blue;">b</span>
<span style="background-color:green;">&nbsp;</span>
<span style="background-color:red;">c</span>
d
jchapa

Try adding &nbsp; inside of the green colored span.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!