有个absolute居中的技巧你可以试下: p{ position: absolute; top:0; left: 0; right: 0; bottom: 0; margin:auto; } 原因:For absolutely positioned elements, the top, right, bottom,and left properties specify offsets from the edge of the element's containing block (what the element is positioned relative to).The margin of the element is then positioned inside these offsets.
方法一:
p{
}
方法2:
p{
}
用了position absolute,margin 0 auto 就没用啦
absolute不适用于margin:0 auto
你要写left: 50%, margin-left :-xxxpx
xxx为你这个p一半的宽度
为什么不用text-align:center
你现在的代码是不是先写{委/3/4002.123...}然后再写的{长宽高},是的话试试把{长宽高}代码的位置提前到{委/3/4002.123...}的前面,不清楚你代码具体的写法,这个小办法估计可能会成
有个absolute居中的技巧你可以试下:
p{
position: absolute;
top:0;
left: 0;
right: 0;
bottom: 0;
margin:auto;
}
原因:For absolutely positioned elements, the top, right, bottom,and left properties specify offsets from the edge of the element's containing block (what the element is positioned relative to).The margin of the element is then positioned inside these offsets.