码迷,mamicode.com
首页 > Web开发 > 详细

CSS - Put a div in the middle of another div

时间:2020-04-27 17:19:13      阅读:70      评论:0      收藏:0      [点我收藏+]

标签:middle   ati   position   pre   center   not   ica   cal   and   

Horizontally center:

.div_out {
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
}

.div_in {
width: 80%;
height: 80%;
background-image: url(../images/bg.jpg);
background-size: 100% 100%;
}

Both horizontally and vertically center:

.div_out {
width: 100vw;
height: 100vh;
}

.div_in {
width: 80%;
height: 80%;
background-image: url(../images/bg.jpg);
background-size: 100% 100%;
position: relative;
left: 10%;
top: 10%;
}


CSS - Put a div in the middle of another div

标签:middle   ati   position   pre   center   not   ica   cal   and   

原文地址:https://www.cnblogs.com/zhangzhihui/p/12787830.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!