gpt4 book ai didi

html - 为什么 <input> 元素在给定宽度时会丢失其左/右边距?

转载 作者:技术小花猫 更新时间:2023-10-29 12:33:37 25 4
gpt4 key购买 nike

以下内容:

<!DOCTYPE html>
<form>
<input type=text>
</form>

在 Chrome 中生成以下盒子模型:

box model no width

但是,如果输入类型的样式带有宽度:

<!DOCTYPE html>
<form>
<input type=text style="width: 100px;">
</form>

删除了左右边距:

enter image description here

这是为什么?

最佳答案

“内在边距的目的是试图防止相邻控件相互对接。尤其是对于圆形控件,这看起来很糟糕。您看到值发生变化的原因是我们只在我们认为它获胜时才设置内在边距' 破坏页面布局。如果作者在控件上指定了明确的高度/宽度,那么我们假设设计人员需要像素精确控制,因此我们关闭边距以避免破坏页面布局.

https://code.google.com/p/chromium/issues/detail?id=128306#c20

关于html - 为什么 &lt;input&gt; 元素在给定宽度时会丢失其左/右边距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20148865/

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