【发布时间】:2020-05-11 13:39:07
【问题描述】:
试图了解两者在用法上的核心区别,但我找不到详细说明此类比较的文章或文档。以here提供的例子为例,假设如下:
div {
background-color: yellow;
width: 120px;
height: 120px;
}
.exampleText {
writing-mode: vertical-lr;
margin-block-start: 20px;
background-color: #c8c800;
}
<div>
<p class="exampleText">Example text</p>
</div>
this instance 和margin-top is used 之间的区别非常小(但可见)。
specifications 表示margin-block-start 取决于布局模型,而margin-top 指的是包含块的宽度。如果有人能用外行的话来解释它会很高兴。
【问题讨论】:
-
指的是包含块的宽度。这仅适用于您使用百分比作为边距值的情况。值的百分比几乎总是使用父块的宽度计算。因此,如果您有一个
margin-top或10%并且您增加了包含块的宽度,则它将是10%相对于包含块的计算宽度。