2014-06-05 41 views
-5

该代码不会工作,你可以帮我或告诉我为什么它不会样式我的HTML。 我试过一切。为什么我的CSS不会在这里工作

<!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> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title><br /> 
<title>twitter</title> 
    <style> 
body background-color: #bbbbbb; 
    #content 
{ border: 1px solid #bbbbbb; width: 80%; background-color: #ffffff; padding: 20px margin: 0 auto; } 
#site_name { border-bottom: 3px soild #bbbbbb; padding-bottom:20px; } 
footer { text-align:center; } 
    </style> 
</head> 

<body> <br /> 
<br /> 
<div id="content"> 
<h1 id="site_name">tweet me</h1> 
<footer> <h6>All rights reserved</h6> 
</footer> </div> 
</body> 
</html> 
+0

http://jigsaw.w3.org/css-validator/ – Quentin

+1

评论如果反对票! – Coops

+1

你对这个CSS有什么期望?什么“不起作用”? – enguerranws

回答

2

修改好了:

  • body background-color: #bbbbbb;改为body {background-color: #bbbbbb; }
  • padding: 20px margin: 0 auto;错过之间的分号。改为padding: 20px; margin: 0 auto;
  • 代替footer { text-align:center; },该H6标签被居中对齐为h6 { text-align:center; }

检查该工作代码:

<!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> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>twitter</title> 
<style> 
    body {background-color: #bbbbbb; } 
    #content 
    { 
     border: 1px solid #bbbbbb; 
     width: 80%; 
     background-color: #ffffff; 
     padding: 20px; 
     margin: 0px auto; 
    } 
    #site_name 
    { 
     border-bottom: 3px solid #bbbbbb; 
     padding-bottom:20px; 
    } 
h6 { text-align:center; } 
    </style> 
</head> 

<body> 
<br /> 
<br /> 
<div id="content"> 
<h1 id="site_name">tweet me</h1> 
<footer> <h6>All rights reserved</h6> 
</footer> </div> 
</body> 
</html> 
+0

在'footer'之后移除':'并将'soild'变成'solid' – fcalderan

4
<style> 
    background-color: #bbbbbb; 
    ... 

您已经定义了一个选择之外的财产。您应该将此属性放在规则中。 可能这会导致剩余规则的解析错误,所以样式不适用。如果你使用验证器,你可以检测到这类问题。

而且,这里

border-bottom: 3px soild #bbbbbb; 

输入错误solid

+0

好的解决我的代码我该如何设计它 – user129923

+0

这是你的问题还是它的声明? – fcalderan

-1
#content 
    { 
     border: 1px solid #bbbbbb; 
     width: 80%; 
     background-color: #ffffff; 
     padding: 20px; 
     margin: 0px auto; 
    } 
    #site_name 
    { 
     border-bottom: 3px solid #bbbbbb; 
     padding-bottom:20px; 
    } 
h6 { text-align:center; } 

添加上面的代码在你的CSS 和尝试,希望它对你有帮助