为什么输入元素的宽度设置不同

发布于 2025-01-04 18:48:13 字数 281 浏览 2 评论 0原文

我很长一段时间都在敲脑袋,不知道设置输入元素的宽度出了什么问题。

这里设置提交按钮的宽度为100px
这里同样将文本字段设置为 100px

并且您可以检查宽度的差异。似乎有人遵循怪癖模式,但是为什么当设置相同的文档类型时?

这是 FX/Chrome 中的错误吗?

I am banging my head for quite a long time and don't what's going wrong with setting width of input elements.

Here 100px set width for submit button
Here same 100px is set to text field

And you can check the difference of width. It seems one is following quirks mode BUT WHY when same doctype is set?

Is it a bug in FX/Chrome?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你与清晨阳光 2025-01-11 18:48:13

通过在输入文本中添加 box-sizing:border-box 即可解决此问题。

因为默认计算宽度和高度时不包含边框,通过添加 box-sizing:border-box 宽度和高度属性的总和包含 padding 和 border,但不包含 margin 将是 100px

http://jsfiddle.net/wizztjh/gn3Cw/6/

更多信息盒子大小

by adding a box-sizing:border-box to input text will solve it.

because the default calculate width and height without the border included , by adding box-sizing:border-box The sum of width and height properties include the padding and border, but not the margin will be 100px

http://jsfiddle.net/wizztjh/gn3Cw/6/

more information of box-sizing

枕花眠 2025-01-11 18:48:13

文本字段具有内置边框。看看删除边框时会发生什么:在这里进行操作

Text fields have built in borders. Look what happens when you remove borders : Fiddle here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文