页面垂直居中

<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

 

posted @ 2018-07-04 11:50  柳州园几声鸣蝉?  阅读(170)  评论(0)    收藏  举报