简体   繁体   English

列表的文字颜色不变

[英]Text color of list not changing

Text color of list is not changing. 列表的文字颜色没有改变。 I'm not sure why. 我不知道为什么。 I made the links a class nav and tried to style that with CSS but it doesn't seem to take effect. 我将链接设置为类nav并尝试使用CSS对其进行样式设置,但它似乎没有生效。

HTML: HTML:

<ul>
    <li><a href="####" class="nav">info</a></li>
    <li><a href="###"  class="nav">facebook</a></li>
</ul>

CSS: CSS:

ul {
    padding-top: 6%;
    right: 9%;
    position: absolute;
    cursor: pointer;
    list-style: none;
}

a .nav {
    font-family: 'Inconsolata', Arial, Helvetica, sans-serif;
    font-size: 10pt;
    letter-spacing: 0px;
    font-weight: 100;
    color: #1B1B1B !important;
}

a .nav needs to be a.nav . a .nav必须是a.nav

a .nav looks for any element with the class nav that is a descendant of an anchor. a .nav查找具有nav类的所有元素都是锚的后代。 a.nav selects anchors that have the class nav. a.nav选择具有nav类的锚。

jsFiddle example jsFiddle示例

Also, whenever possible, try to avoid using !important . 另外,请尽可能避免使用!important

Your element selector a .nav had space, change it to : a .nav元素选择器有空格,请将其更改为:

a.nav {
    font-family: 'Inconsolata', Arial, Helvetica, sans-serif;
    font-size: 10pt;
    letter-spacing: 0px;
    font-weight: 100;
    color: #1B1B1B;
}

or like this one : 或喜欢这个:

.nav a{
    font-family: 'Inconsolata', Arial, Helvetica, sans-serif;
    font-size: 10pt;
    letter-spacing: 0px;
    font-weight: 100;
    color: #1B1B1B !important;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM