开发者

Centering children of a div without using <center>

The center tag is deprecated. I should not use it anymore. However, I haven't been able to reproduce the following with using center:

<div><center><span>Test<span> <span>Test<span> <span>Test<span></center></div开发者_运维百科>

I have tried using margin: 0 auto and align: center but both don't work: http://jsfiddle.net/zTY4f/


margin: 0 auto works if you explicitly set a width as well.

div {
    width: 400px;
    margin: 0 auto;
}


use css:

div {
    text-align:center;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜