電子メールとパスワードの幅がinput-container
の幅を外れているのはなぜですか?あなたはパディングを設定しているためだCSS入力エレメントの幅がコンテナの外に出る
form {
background: #ccc;
}
.input-container {
background: red;
width: 469px;
margin: 0 auto;
}
.usermail,
.userpword {
margin-top: 10px;
}
input,
button {
width: 100%;
border-radius: 6px;
border: 1px solid #cacece;
padding: 10px 12px;
font-size: 1em;
}
.username input {
width: 206px;
}
<form action='' method='post' id='signupform'>
<div class='input-container'>
<div class='username'>
<input type='text' name='fname' id='fname' placeholder='First Name'>
<input type='text' name='lname' id='lname' placeholder='Last Name'>
</div>
<div class='usermail'>
<input type='email' name='email' id='email' placeholder='Email'>
</div>
<div class='userpword'>
<input type='password' name='pword' id='pword' placeholder='Password'>
</div>
<button>Sign Up</button>
</div>
</form>
あなたのパディングは幅にはカウントされませんので、そうあなたの入力は '100%+パディング 'です。この問題を解決するには 'box-sizing:border-box'を使います。また、あなたの国境にも同じことが言えます。 – somethinghere
[CSS入力の幅:100%が親の範囲外になる]重複している可能性があります(http://stackoverflow.com/questions/16907518/css-input-with-width-100-goes-outside-parents-bound) – showdev
^Googleの "CSS Box Model" –