为什么边距和填充在Opera中正常工作但在IE 8和FF 3.6中没有?

时间:2011-02-02 10:34:26

标签: css internet-explorer firefox

HTML代码:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>CSS Test Page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
    body
    {
        margin: 0;
        padding: 0;
    }
    #int
    {
        width: 1000px;
        text-align: justify;
        border: solid 1px #000;
    }
    </style>    
        </head>
<body>

<div id="int">
Some simple text...
</div>

</body>
</html>

结果如下: Opera 11 enter image description here 这有效!

但是... Internet Explorer 8 enter image description here ...和 Firefox 3.6 enter image description here

问题仅在于此代码使用Yii Web App的布局... 哪里错了?求助。

P.S。 kennel.cms.ua - 此站点在本地Web服务器上运行:)

2 个答案:

答案 0 :(得分:1)

如果你真的想拥有跨浏览器的支持,我会,如果我是你,那就做得很好。

  

在玩CSS之前添加 CSS重置

有很多,只是使用它。

如果你想知道什么是最好的CSS重置,我会鼓励你read this question

答案 1 :(得分:0)

你是抱怨因为FF和IE中存在的margin-top,但是在Opera?

尝试在CSS中设置这些属性。

display: inline;
float: left;
height: auto;
position: relative;
text-align: left;
width: 100%;

我认为它会解决你的问题:D