css - margin:0 auto 没有起到作用
PHP中文网
PHP中文网 2017-04-17 13:49:55
[HTML讨论组]
在IE8下运行此段代码  没有居中  除了body设置text-align:center  还有其它解决方法吗?
<!doctype html>
<html>
    <head>
        <style>
            .tcenter{
                width:500px;
                margin:0 auto;
            }
        </style>
    </head>
    <body>
        <p class="tcenter">没有居中。。</p>
    </body>
</html>
PHP中文网
PHP中文网

认证0级讲师

全部回复(3)
PHPz

亲测IE8居中没问题

你要文字居中就设置.tcenter{text-align:center}

margin:0 auto; 是让p居中的,不是让文字居中的。

PHP中文网

把效果图发上来,你认为的居中是怎样居中。

天蓬老师

IE8的bug。
解决方案:ie8下面margin:0 auto;不能居中的解决方案,ie8兼容性代码
相关问题:Using “margin: 0 auto;” in Internet Explorer 8

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号