gpt4 book ai didi

html - 如何将 margin-top 应用于 标签?

转载 作者:搜寻专家 更新时间:2023-10-31 08:07:10 24 4
gpt4 key购买 nike

我想设置margin-top<small>标签。换句话说,我怎样才能增加 <small> 的空间?用上层元素标记?

注意:我可以使用 line-height 增加空间, 但我只想从顶部设置空间,而不是顶部和底部。

small{
margin-top: 100px;
color: #999;
}
<div>It is a test<div>
<small>this need to some margin-top</small>

我该怎么做?

最佳答案

Box Model - 8.3 Margin properties

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.

small 标签默认是 inline。正如上面的规范所述,垂直边距不适用于严格的 inline 级别元素。

您可以将 display 更改为 inline-block,它会按预期工作:

small {
margin-top: 100px;
color: #999;
display: inline-block;
}
<div>It is a test<div>
<small>this need to some margin-top</small>

关于html - 如何将 margin-top 应用于 <small> 标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33710333/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com