html - 为什么我的页面在标准模式下会严重中断?

标签 html css quirks-mode

我的页面在文档类型方面非常完美,但在应用文档类型时会严重崩溃。 (更具体地说,它破坏了任何 HTML4 文档类型。HTML3 文档类型可以正常工作,但这显然是 Not Acceptable 。)

通常,我已将页面缩减为仅包含演示问题所需的最少内容,但主要问题仍然存在。

没有文档类型,需要: desired

使用文档类型,严重损坏: enter image description here

当然还有代码。添加一个文档类型来打破它。

<html>
<head>
<title>Test</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>


<div id="container1">
  <div id="main"></div>
</div>

<div id="container2">

    <div id="test1">
      <p style="text-align: center;">content goes here</p>
    </div>

    <div id="test2">
      <p style="text-align: center;">more content goes here</p>
    </div>

</div>

</body>
</html>

和 style.css:

body
{
  margin: 0px;
  overflow:hidden;
  color: white;
  background-color: black;
  text-transform: lowercase;
  height: 100%;
}

#container1
{
  background-color: black;
  width: 100%;
  height: 75%;
  margin-left: auto;
  margin-right: auto;
  margin-top: 0%;

}

#main
{
  width: 800px;
  height: 480px;
  margin-left: auto;
  margin-right: auto;
  position: relative;
  background-color: blue;
}

#container2
{
  background-color: black;
  width: 100%;
  height: 22%;
  margin-left: auto;
  margin-right: auto;
  position: relative;


}

#test1
{
  position: absolute;
  width: 50%;
  height: 100%;
  background-color: blue;
}

#test2
{
  position: absolute;
  width: 50%;
  margin-left: 50%;
  height: 100%;
  overflow: auto;
  background-color: green;
}

最佳答案

现场演示: http://jsfiddle.net/ZcYwQ/

  1. html { 高度:100%; }
  2. 左:0; bottom:0;right:0; bottom:0; 在#test1 和#test2 元素上

关于html - 为什么我的页面在标准模式下会严重中断?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4907601/

相关文章:

javascript - 滚动上响应式固定导航样式

javascript - 如何以最简单的方式 trim `html` 文本并将其传递给变量?

html - 为同一页中的两个表添加标题

internet-explorer - HTML/DOM : What is standards equivalent of document. body.scrollHeight?

html - 标题文本不会到达代码底部

html - 如何让 <a> 元素填充此表中的 <li> 以便每个单元格都是一个链接而不仅仅是文本?

html - 如何将我的链接移动到提交按钮的右侧

html - 响应式设计和网格 : Where should I put the navbar to?

javascript - jQuery 的 :hidden selector not working in IE9 Quirks Mode

html - 强制 IE9 进入浏览器兼容性 View