首页 > 试题广场 >

执行以下程序,当为son盒子添加CSS样式:margin-t

[单选题]

执行以下程序,当为son盒子添加CSS样式:margin-top:20%;时,效果为()

.father {

    width: 200px;

    height:100px;

    border:1px solid red;

}
.son {

    height:50px;

    width:50px;
}

<div class="father">

    <div class="son"></div>

</div>

  • father盒子带着son盒子一起下移40px

  • father盒子带着son盒子一起下移20px

  • son盒子下移20px,father盒子不动

  • son盒子下移40px,father盒子不动

margin 的百分比值参照其包含块的宽度进行计算。但这只发生在默认的 writing-mode: horizontal-tb; 和 direction: ltr; 的情况下。

当书写模式变成纵向的时候,其参照将会变成包含块的高度。

发表于 2025-10-28 11:02:39 回复(0)