韶光密林
2016-07-06 10:05
超出屏幕宽度的容器想要水平居中,还是要用relative的吧?
.content{
width: 1920px;
margin-left: auto;
margin-right: auto;
height: 30px;
box-shadow: 0 0 5px 1px #333;
}.content{
width: 1920px;
position:relative;
top: 0;
left: 50%;
margin-left: -960px;
height: 30px;
box-shadow: 0 0 5px 1px #333;
}虽然都是居中,但好像有明显区别。
第二段代码中的left设为百分之50的话应该是没有算进去想要居中物体本身的宽度的吧
CSS深入理解之relative
47913 学习 · 28 问题
相似问题