绝对定位居中

CSS:

.box .c {

    width: 960px;

    height: 69px;

    background-color: pink;

    /*margin: 0 auto;*/

    position: relative;

    left: 50%;

    margin-left: -480px;

    /*设置绝对定位之后,margin:0 auto;不起任何作用,如果想让绝对定位的盒子居中。当做公式记下来 设置子元素绝对定位,然后left:50%; margin-left等于元素宽度的一半,实现绝对定位盒子居中*/

}
原文地址:https://www.cnblogs.com/nzd123456/p/9855065.html