CSS
在 body
中居中一个 div
html {
height: 100%;
}
body {
height: 100%;
margin: 0;
padding: 0;
}
.container {
height: 100%;
width: 100%;
display: table;
}
.main {
display: table-cell;
height: 100%;
vertical-align: middle;
text-align: center;
}
<div class="container">
<div class="main">
Stuff
</div>
</div>