gpt4 book ai didi

css - Box-Sizing 似乎并没有像我期望的那样尊重填充

转载 作者:太空宇宙 更新时间:2023-11-04 03:51:20 24 4
gpt4 key购买 nike

有人能告诉我为什么在给定以下 fiddle example 的情况下,盒子大小似乎不符合 div 中的填充吗?

// The code is too long for this but can be viewed using browser debugging tools
// and here is a picture that says it all.

enter image description here

左栏固定宽度:190px;

右列宽度:100%,左边距:190px

绿色的div是没有宽高的嵌套div:20px;

 <style>
div {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
</style>

padding 不应该将绿线插入左侧吗?

最佳答案

本例中的问题出在 #wizard-body div 上,它有一个左边距,但宽度也为 100%,这意味着它太宽了对于它的容器。 float 也搞砸了。删除这些,它将按预期工作:

#wizard-body {
float: left;
width: 100%;
}

绿色 div 的行为符合预期,但在屏幕外跟随容器。

关于css - Box-Sizing 似乎并没有像我期望的那样尊重填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23337675/

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