我創建了一個當前適合整個屏幕寬度的登錄表單。我試圖通過使用寬度來縮小窗體的寬度:50%,它完美地確定窗體的大小,但是使窗體粘在屏幕的左側。我如何改變表單大小,同時使其集中和響應?有沒有簡單的屬性,我不知道?如何使登錄表單不適合屏幕的整個寬度
html,
body {
height:100%;
font-family: 'Alegreya Sans', sans-serif;
}
#header {
background:linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('../img/hero.jpeg') center center no-repeat;
background-size:cover;
height:100%;
color:white;
display:flex;
align-items:center;
}
#header h1 {
text-align: center;
font-family: 'Raleway', sans-serif;
font-size: 500%;
font-weight: 300;
}
#header h3 {
text-align: center;
font-family: 'Raleway', sans-serif;
font-size: 200%;
font-weight: 100;
}
.login {
background-color:rgba(0,0,0,0.5);
padding:30px;
border-radius:10px;
}
<section id="header">
<div class="col-sm-12 login">
<h1>Apple ID</h1>
<h3>Manage your Apple account</h3>
<form>
<fieldset class="form-group">
<label class="sr-only">Apple ID</label>
<input type="email" class="form-control" placeholder="Apple ID">
</fieldset>
<fieldset class="form-group">
<label class="sr-only">Password</label>
<input type="password" class="form-control" placeholder="Password">
</fieldset>
<button type="submit" class="btn btn-outline-info btn-block">login</button>
</form>
</div>
</section>
這與margin:0 auto;訣竅!謝謝! – YoungCoder