为什么输入元素的宽度设置不同
我很长一段时间都在敲脑袋,不知道设置输入元素的宽度出了什么问题。
这里设置提交按钮的宽度为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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是因为边框尺寸
试试这个,
http://jsfiddle.net/gn3Cw/2/
http://jsfiddle.net/gn3Cw/3/
it is because of the border size
try this,
http://jsfiddle.net/gn3Cw/2/
http://jsfiddle.net/gn3Cw/3/
通过在输入文本中添加
box-sizing:border-box
即可解决此问题。因为默认计算宽度和高度时不包含边框,通过添加
box-sizing:border-box
宽度和高度属性的总和包含 padding 和 border,但不包含 margin 将是 100pxhttp://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 100pxhttp://jsfiddle.net/wizztjh/gn3Cw/6/
more information of box-sizing
文本字段具有内置边框。看看删除边框时会发生什么:在这里进行操作
Text fields have built in borders. Look what happens when you remove borders : Fiddle here