父盒子
.login{
position: absolute;
width: 100%;
height: 100%;
background-color:cyan;
}
子盒子
.loginForm{
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
background-color:#ffffff;
width: 400px;
height: 300px;
margin: auto;
}
这篇文章展示了如何使用CSS进行绝对定位,创建一个全屏的父盒子(背景色为青色)以及在其中居中的子盒子(白色,固定尺寸)。子盒子通过left,right,bottom,top属性实现内部居中,并设定固定宽高。
1529

被折叠的 条评论
为什么被折叠?



