CSS - Put a div in the middle of another div

2021-03-17 10:24

阅读:430

标签: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


评论


亲,登录后才可以留言!