css实现块级元素的水平居中的2种常用方法
第一种:
利用margin来水平居中
.bl{
margin: 0 auto;
background: red;
width: 100px;
height: 100px;
}
第二种:利用百分比,利用50%,然后减去自己的一半.
.bl2{
position: relative;
left: 50%;
width: 200px;
height: 200px;
background: green;
margin-left: -100px;
}
博客园的文章都是大学时写的,质量不太好。
我的新文章都会发布再新的 blog :https://blog.biyongyao.com
请大家关注哟!!