gpt4 book ai didi

html - html和css的背景问题

转载 作者:太空宇宙 更新时间:2023-11-04 02:31:09 25 4
gpt4 key购买 nike

我将其作为 html:

   <div id="subNav" class="lib"><a href="./?c=library&amp;page=1">A Page</a> &nbsp;|&nbsp;
<a href="./?c=library&amp;page=2">Another Page</a> &nbsp;|&nbsp;
<a href="./?c=library&amp;page=3">Third Item</a>
</div>

这是与之关联的 CSS:

/*** SubNav styles ***/

#subNav {
position: relative;
top: -38px;
right: -356px;
/* background: #f39327; */
width: 380px;
height: 22px;
font-size: 18px;
color: #ffffff;
font-weight: normal;
text-align: right;
vertical-align: middle;
display: table;
display: table-cell;
line-height: 22px;
/* border: 2px solid #f39327; */
border-radius: 0 0 0 9px;
padding-right: 60px;
}

#subNav a:link, #subNav a:visited {
color: #ffffff;
text-decoration: none;
}

#subnav.lib {
background: #f39327;
}

#subNav.lib a:hover, #subNav.lib a:active {
color: #efefef;
text-decoration: none;
}

如果我在 #subNav 中设置了 subNav 背景颜色,它就可以正常工作。但是当我尝试在 .lib 部分中设置它时,它没有。我不想总是将它设置为一种特定的颜色,因为我希望 subNav 功能根据类别更改颜色,因为网站的其他部分有其他颜色主题。为什么它在类环境中不起作用,我需要做些什么才能让它以这种方式起作用?

最佳答案

CSS 区分大小写。

CSS is case insensitive in all matters under its control; however, some things, such as the document markup language, are beyond its control. HTML is case insensitive in most respects, except when it comes to certain attribute values, like the id and class attributes. XHTML, being XML, is always case sensitive.

您必须将 #subnav.lib 更改为 #subNav.lib 以便您的最终代码如下所示

#subNav.lib {
background: #f39327;
}

关于html - html和css的背景问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36491831/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com