100% の幅とマージン/パディングで入力を使用する方法??
入力にフォーカスがない場合、幅は親要素よりも 2 ピクセル広くなりますが、フォーカス時には幅は正しいですか? これを解決する方法は?! :-/
jsfidle
コード
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>