0
我在垂直和水平方向上居中放置一個表單,我已經設置了水平居中表單,但無法設置垂直居中而不導致表單和圖像重疊。在頁面底部還有多個圖片橫向居中的問題。定位表單和多個圖像
.banner {
position: relative;
width: 100%;
top: 0;
left: 0;
padding: 0;
margin: 0;
background-color: #595959;
color: #fff;
text-align: center;
font-family: 'Lato', sans-serif;
font-size: 25px;
padding-top: 50px;
}
#imagesMain {
position: relative;
max-width: 75rem;
left: 0;
right: 0;
margin: auto;
bottom: 0;
padding: 0;
margin: 20px auto;
text-align: center;
}
#imagesMain a {
width: 30%;
float: left;
position: relative;
margin: 1.5%;
}
img {
max-width: 100%;
height: auto;
margin-right: 25px;
position: relative;
}
body,
html {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
body {
vertical-align: middle;
}
#form {
display: table;
margin: 0 auto;
}
<!DOCTYPE html>
<body>
<div class="banner">
<h1>A-Level Revision Website</h1>
</div>
<div id="form">
<form id="loginForm">
<input type="email" class="login-username" autofocus="true" required="true" placeholder="Email" /><br>
<input type="password" class="login-password" required="true" placeholder="Password" /><br>
<input type="submit" name="Login" value="Login" class="login-submit" /><br>
<a href="#" class="login-forgot-pass">forgot password?</a>
</form>
</div>
<div id="imagesMain">
<a href="Maths.html">
\t \t \t <img src="https://i.pinimg.com/originals/06/9a/c8/069ac81cbe0e3a6f8fb43a0df42125a0.jpg" alt="Maths"">
\t \t </a>
<a href="ComputerScience.html">
<img src="https://i.pinimg.com/originals/06/9a/c8/069ac81cbe0e3a6f8fb43a0df42125a0.jpg" alt="ComputerScience">
</a>
<a href="Physics.html">
\t \t \t <img src="https://i.pinimg.com/originals/06/9a/c8/069ac81cbe0e3a6f8fb43a0df42125a0.jpg" alt="Physics"">
\t \t </a>
</div>
</html>
使登錄表單在整個頁面的中心垂直和水平居中,圖像水平居中在頁面底部。 – user7808079