html – 如何在css中进行输入并选择相同的宽度

在我的页面中,有几个输入和选择标签.

我用宽度:100%;定义它们的宽度,但浏览器中的宽度不是100%.

我在chrome中使用了调试工具,发现还应用了useragent样式表样式.

如何使宽度100%?

解决方法

Demo Fiddle

理想情况下,您应该将样式与内容分开,因此在CSS中包括

input,select{
  width:100%;
  Box-sizing:border-Box;
}

NB. demo fiddle without box-sizing set

并且您需要使用Box-sizing:border-Box来调整大小以考虑任何特定于浏览器或设置边距/填充/边框. Here’s a handy read on the subject.

Box-Sizing on MDN:

The Box-sizing CSS property is used to alter the default CSS Box model
used to calculate widths and heights of elements. It is possible to
use this property to emulate the behavior of browsers that do not
correctly support the CSS Box model specification.

border-Box

The width and height properties include the padding and border,but not the margin. This is the Box model used by Internet Explorer when the document is in Quirks mode.

相关文章

vue阻止冒泡事件 阻止点击事件的执行 <div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些