Header 未使用 CSS 更改样式,但其他 div 是

Header not changing style using CSS, however other div is

我正在尝试使用 css 让我的 header 背景改变颜色,但是除了我的导航 <div>.[=16] 的位置,我无法改变任何东西=]

https://jsfiddle.net/70d40nnt/2/

<style type="text/css">
#header {
    background:#7D72F7;
    text-align:center;
    padding:5px;
}
.clearfix {
    overflow: auto;
}
#nav {
    line-height:30px;
    background-color:#eeeeee;
    height:200px;
    width:150px;
    float:right;
    padding:5px; 
    text-align:center;
}
#section {
    width:350px;
    padding:10px; 
    float:left;
}
</style>

从您的样式表中删除 <style></style>,您的 jsfiddle 就可以工作了。实际上,只有 html 页面中的 css 指令才需要它们。

只需从 "CSS" 框中删除 <style> 标签(并从 "HTML" 框中删除 <body>),它就会起作用。

在 js fiddle 中删除 css 块中的样式标签。 JS fiddle 不需要定义样式标签。直接写样式。