您的位置:首页 > Web前端 > CSS

css设置div垂直居中显示

2017-03-29 13:51 435 查看
css设置div垂直居中显示:

css样式:

.parent{

width:100%;
height:700px;
background-color: cyan;
position: relative;

}

.child{

width:400px;

height:400px;

background-color:#000;

position: absolute;  

left: 50%;

top: 50%;

margin-left: -200px;  

margin-top: -200px;  

}

html结构:

<div class="parent">
<div class="child">

</div>

</div>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: