如何使用具有 100% 宽度和边距/填充的输入?
当输入没有焦点时,宽度比父元素宽 2 像素,但在焦点上宽度是否正确?这个怎么解决?!:-/
js文件
代码
input, textarea {
width:100%;
-moz-box-sizing:border-box;
-ms-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
}
input, textarea, button {
display:inline-block;
font-family:arial;
margin:1px;
}
input, textarea {
background-color:#FFFFFF;
border:1px solid #297296;
color:#333333;
font-size:12px;
padding:4px 4px;
}
input:focus, textarea:focus {
border-color:#1a4c91;
box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.07), 0 0 6px #7ab5d3;
border-width:2px;
margin:0px;
}
<div style="margin-top:20px; margin-left:20px">
<div style="width:100px; background:red; float:left; margin:1px">
<input type="text">
</div>
<div style="width:100px; background:red; float:left; margin:1px">
<input type="text">
</div>
</div>