我有这个HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <link href="css/test.css" rel="stylesheet">
</head>
<p></p>
<h2>Meeting the Old Guard  </h2>
<p>I was shot in Vietnam by an old man. .</p>
</body>
</html>


这个CSS样式表名为test.css

body {
    width: 100%;
    margin-right: auto;
    margin-left: 2cm;
    color: #f0f;
    background-color: #000;
    margin-left: max-width: 1400px; }
}

h2 {
    color: #fff;
    margin-left: 0;
    font-weight: 700;
    font-style: italic;
}

p {
    color: #fff;

}


body标签指定洋红色。 h2标签和p标签指定白色。但是,h2呈现为洋红色,段落变为白色。标题为何不呈现白色?

最佳答案

您的身体标签上有一个额外的支架

body {
width: 100%;
margin-right: auto;
margin-left: 2cm;
color: #f0f;
background-color: #000;
margin-left: max-width: 1400px; }


}
检出https://jsfiddle.net/bryanseven/vvw3k7to/可以正常工作。

关于html - CSS无法在标题标签上工作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31866746/

10-12 00:04
查看更多