你已经设置width并height在这两个DIV,那么你可以使用这样的代码:
.wrapper {
position: absolute;
top: 50%;
left: 50%;
margin-top: -170px;
margin-left: -300px;
}
.wrapper2 {
position: absolute;
top: 50%;
left: 50%;
margin-top: 150px;
margin-left: -300px;
}
Run Code Online (Sandbox Code Playgroud)
有了top: 50%; left: 50%,你把div的左上角放在中间,然后用/正/负边距调整它的位置.
JsFiddle(一个有自己风格的基本款)
| 归档时间: |
|
| 查看次数: |
19890 次 |
| 最近记录: |