【问题标题】:Weird quirks mode problem奇怪的怪癖模式问题
【发布时间】:2011-04-06 18:17:17
【问题描述】:

在我的电脑上,我开发的网站在 IE 中看起来不错,但在 Web 服务器上,布局“损坏”(IE)

这是我的文档类型

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

在 localhost 文档模式为 IE8 标准

在网络服务器上是:怪癖

代码如下:

<!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" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
        <style type="text/css" media="screen">
            body{
                font: 11px Tahoma, Verdana, Arial, sans-serif;
                color: #707070;
                background: #8c2727 url('../img/bgr_red.png') repeat-x;
            }

            a {
                color:#bc2828;
                text-decoration:none;
                font-weight: bold;
                outline: none;
            }


            #wrapper{
                position: relative;
                width: 960px;
                margin: 70px auto;
                background-color: #fff;
                border: 1px solid red;
            }

        </style>
    </head>

    <body>
    <div id="wrapper">
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    </div>
    </body>
    </html>

这是第一次发生在我身上吗?如何解决?

【问题讨论】:

  • 网站的 URL 可以更容易地识别正在发生的事情
  • @David Dorward 我已经编辑了我的帖子。见上文。
  • 那么...最后,您实际使用的文档类型是哪一种? :)

标签: html css


【解决方案1】:

您缺少mode switching meta tagI recommended in my answer to your last question.

<meta http-equiv="X-UA-Compatible" content="IE=edge"> 

此外,您代码中的 Doctype 与您说您正在使用的 Doctype 不同(两者都应该触发标准模式,但是当您做什么和您说什么时很难调试做的是不同的事情!!)。

【讨论】:

最近更新 更多