开发者

Centering children of a div without using <center>

开发者 https://www.devze.com 2023-04-12 17:02 出处:网络
The center tag is deprecated. I should not use it anymore. However, I haven\'t been able to reproduce the following with 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

精彩评论

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