页面垂直居中

<div id="popup"></div>

需要定义heigh 和width

#popup
position:fixed
left:0
right:0
top:0
bottom:0
width:100px
height:100px
margin:auto
background:red
color:#fff

不需要定义高宽

#popup
position: fixed;
left: 50%;
top:50%;
background: rgba(0,0,0,.35);
padding: 10px;
border-radius: 5px;
transform: translate(-50%,-50%);
color:#fff

猜你喜欢

转载自www.cnblogs.com/liuzhouyuan/p/9262582.html