一、水平居中
.hor_center {
margin: 0 auto;
}二、水平垂直居中
<div class="content"></div>
.content {
width: 360px;
height: 240px;
}
.ver_hor_center {
position: absolute;
top: 50%;
left: 50%;
margin-left: -180px; /*要居中的div的宽度的一半*/
margin-top: -120px; /*要居中的div的高度的一半*/
}三、div置于底部(footer)
.bottom_footer {
position: fixed; /*or前面的是absolute就可以用*/
bottom: 0px;
}
本文详细介绍了网页布局中实现水平、垂直居中的CSS技巧,并通过实例展示了如何使用绝对定位使div元素居于页面底部。文章旨在帮助开发者掌握布局元素的关键技能。
2351

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



