我一直在使用編碼的HTML和CSS網站,最近我已經到了需要與背景顏色的div元素。我在background-color: gray;
,但沒有奏效。我使用了Google Chrome的檢查元素功能,並且表示Chrome無法識別該元素。我在Firefox中使用了相同的功能,它也無法識別CSS元素。該div包含三個浮動部分,但它使用overflow: auto
,所以這不是問題。有人可以向我解釋爲什麼我不能添加背景顏色到我的div?DIV背景顏色不起作用
HTML:
<div id="main">
<header>
<h1>LOGO</h1>
<nav>
<a href="index.html" title="Home">Home</a>
<a href="about.html" title="About">About</a>
<a href="features.html" title="Features">Features</a>
<a href="specs.html" title="Specifications">Specs</a>
<a href="updates.html" title="Updates">Updates</a>
<a href="contact.html" title="Contact Us">Contact</a>
</nav>
</header>
<section class="left">
<h2>NEWS</h2>
<p>Itate eaquid quodit, utem dolorenihit ullore ides est faccum simaiorrum accaerf erfercim voloremod ut volectem con cus, temoluptatur as disquatent.</p>
</section>
<section class="right">
<h2>SOMETHING</h2>
<p>Itate eaquid quodit, utem dolorenihit ullore ides est faccum simaiorrum accaerf erfercim voloremod ut volectem con cus, temoluptatur as disquatent.</p>
</section>
<section class="right">
<h2>SOMETHING</h2>
<p>Itate eaquid quodit, utem dolorenihit ullore ides est faccum
simaiorrum accaerf erfercim voloremod ut volectem con cus,
temoluptatur as disquatent.</p>
</section>
</div>
CSS:
#main {
backgound: gray;
layer-background: gray;
overflow: auto;
border: 2px dashed black;
border-radius: 15px;
-moz-border-radius: 15px;
}
section {
background-color: green;
text-align: justify;
margin: 5px;
padding 10px;
border-radius: 10px;
-moz-border-radius: 10px;
}
請張貼元素的HTML和CSS(有選擇)。 – Bojangles