div绝对定位居中

绝对定位absolute,left:50%,加上margin-left:-(宽度/2),可以实现绝对位置居中

.list{
1200px;
height: 300px;
overflow: hidden;
position: absolute;
left: 50%;
margin-left: -600px;
}

上面是早期使用的绝对定位实现水平居中,但是缺点是,常常不知道元素的宽度是多少。
https://www.w3cplus.com/css/elements-horizontally-center-with-css.html(6种实现元素水平居中的方法)
原文地址:https://www.cnblogs.com/hfeng007/p/9292800.html