2014-04-02 62 views
-2

我有DOCTYPE声明的问题,似乎当我添加它,在我的页面上,CSS犯规work.But当我删除的文档类型,一切正常fine.what可能是原因文档类型不工作,因为它应该是

HTML

<!DOCTYPE html> 
<html> 
<head> 
<link rel="stylesheet" type="text/css" href="style.css"/> 
</head> 
<body> 
<div id="wrapper"> 
    <div id="header">this is my header 
    </div> 
    <div id="center_content"> 
     <div id="left"> 
     </div><div id="right"></div> 
    </div> 
    <div id="footer">this is my footer 
    </div> 
</div> 
</body> 
</html> 

CSS

body 
{ 

margin:0px; 
padding:0px; 

} 
#wrapper 
{ 
height:100%; 
width:100% 
} 
#header 
{ 
width:100%; 
height:20%; 
background-color:red; 
} 
#center_content 
{ 
min-height:79%; 
height:auto; 
background-color:pink; 
overflow:auto; 

} 
#footer 
{ 
height:5%; 
background-color:blue; 
} 
#left 
{ 
float:left; 
min-height:79%; 
height:auto; 
width:20%; 
background-color:brown; 
} 
#right 
{ 
float:right; 
min-height:79%; 
height:auto; 
width:79%; 
background-color:yellow; 

} 
+1

Live link?检查您的控制台的错误,也因为您使用的HTML5文档,你不需要设置一个类型的CSS链接 –

+3

我认为你有一个不同的标准“应该”的定义。 – BoltClock

+0

同样使用十六进制/ rgb/rgba而不是红色,粉红色...... –

回答

0

您的文档类型不是问题。您只需了解使用%百分比时,还应该向父母/祖先声明百分比宽度和高度,即<html><body>。

我修改了你的css。尝试这个。

html, body { 
    margin:0px; 
    padding:0px; 
    width: 100%; 
    height: 100%; 
} 
#wrapper { 
    height:100%; 
    width:100%; 
} 
#header { 
    width:100%; 
    height:20%; 
    background-color:red; 
} 
#center_content { 
    height:79%; 
    background-color:pink; 
    overflow:auto; 
} 
#footer { 
    height:5%; 
    background-color:blue; 
} 
#left { 
    float:left; 
    height:100%; 
    width:20%; 
    background-color:brown; 
} 
#right { 
    float:right; 
    height:100%; 
    width:79%; 
    background-color:yellow; 
} 

所以,当你删除了doctype它Quirks Mode进入这就是为什么它呈现细微没有DOCTYPE。

相关问题