我想设置margin-top到<small>标签.换句话说,我如何<small>用上部元素增加标签的空间?
注意:我可以使用增加空间line-height,但我只想从顶部设置空间,而不是从顶部和底部设置空间.
small{
margin-top: 100px;
color: #999;
}Run Code Online (Sandbox Code Playgroud)
<div>It is a test<div>
<small>this need to some margin-top</small>Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
边距属性指定框的边距区域的宽度.'保证金'速记属性设定所有四边的保证金,而其他保证金属性仅设定各自的边.这些属性适用于所有元素,但垂直边距不会对未替换的内联元素产生任何影响.
一个small标记为inline默认.如上面的规范所述,垂直边距不适用于严格inline级别的元素.
您可以更改display为inline-block,它将按预期工作:
small {
margin-top: 100px;
color: #999;
display: inline-block;
}Run Code Online (Sandbox Code Playgroud)
<div>It is a test<div>
<small>this need to some margin-top</small>Run Code Online (Sandbox Code Playgroud)