[英]CSS vertical align of inline-block not working
HTML: HTML:
<div id='inner'>I am sam <em>I am em</em> I am sam</div>
CSS: CSS:
#inner {
width: 400px;
height: 400px;
background-color: cyan;
}
em {
margin: 1em;
padding: 1em;
display: inline-block;
vertical-align: top;
}
Result: https://jsfiddle.net/cbukkt3m/1/ 结果: https : //jsfiddle.net/cbukkt3m/1/
Why does it throw the surrounding text to the top and not the em itself? 为什么将周围的文本放在顶部而不是em本身?
It is aligned to the top, it's being pushed down by: 它与顶部对齐,并通过以下方式向下推:
margin: 1em;
padding: 1em;
try removing these or changing them to 尝试删除这些或将它们更改为
margin: 0 1em;
padding: 0 1em;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.