在我的导航栏中有这段代码。
<div id="aboutnav"><a class="hl" href="#"><h2>about\a</h2></a></div>
所有 div 在这种情况下所做的就是将文本放在适当的位置,而在 a.hl 中它是 -
a.hl{
background-color:#000;
text-decoraction:none;
color:#fff;
}
文本颜色正确,位置正确,但没有背景颜色。
最佳答案
这是因为在 HTML4/XHTML 中你不能将 hx 元素嵌套到 a!尝试改用它:
<div id="aboutnav"><h2><a class="hl" href="#">about\a</a></h2></div>
我认为您需要以类似的方式更新您的 css:
a.hl{
display:block;
background-color:#000;
text-decoraction:none;
color:#fff;
}
关于css-背景色:#xxxxxx; not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7134274/