为什么不能 <span>
有一个负的垂直边距或填充?
如果我将它设置为 display: block
, 它仍然不起作用。
最佳答案
来自 CSS 2.1 规范:
8.3 Margin properties: 'margin-top', 'margin-right', 'margin-bottom', 'margin-left', and 'margin'
Margin properties specify the width of the margin area of a box. The 'margin' shorthand property sets the margin for all four sides while the other margin properties only set their respective side. These properties apply to all elements, but vertical margins will not have any effect on non-replaced inline elements.
<span>
默认情况下,是一个不可替换的内联元素。
还有
8.4 Padding properties: 'padding-top', 'padding-right', 'padding-bottom', 'padding-left', and 'padding'
...
Unlike margin properties, values for padding values cannot be negative.
关于html - 给 `<span>` 负垂直边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13537255/