Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 无法更改<;a>;字体颜色_Css - Fatal编程技术网

Css 无法更改<;a>;字体颜色

Css 无法更改<;a>;字体颜色,css,Css,我无法更改菜单中的第五个元素。它应该有蓝色的背景(它的作品),但我不能改变字体颜色为白色 CSS ul li:nth-child(5) { background-color: #006db6; width: 100px; margin: 0 auto; border-radius: 5px; } ul a:nth-child(5) { color: #FFF; } HTML <nav> <ul>

我无法更改菜单中的第五个元素。它应该有蓝色的背景(它的作品),但我不能改变字体颜色为白色

CSS

ul li:nth-child(5)
{
    background-color: #006db6;
    width: 100px;
    margin: 0 auto;
    border-radius: 5px;
}

ul a:nth-child(5)
{
    color: #FFF;
}
HTML

     <nav>
        <ul>
            <li><a href="#">Services</a></li>
            <li><a href="#">Pricing</a></li>
            <li><a href="#">Training</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Login</a></li> <!-- This element should has other background and font -->
            <li><a href="#">01276 819291</a></li>
        </ul>
    </nav>


您只需重用与要影响的
元素的父元素相同的伪选择器即可

ul li:nth-child(5) {
    background-color: #006db6;
    width: 100px;
    margin: 0 auto;
    border-radius: 5px;
}

ul li:nth-child(5) a {
    color: #fff;
}

您可以重用与要影响的
a
元素的父元素相同的伪选择器

ul li:nth-child(5) {
    background-color: #006db6;
    width: 100px;
    margin: 0 auto;
    border-radius: 5px;
}

ul li:nth-child(5) a {
    color: #fff;
}

我猜
a
在第5个
li
子项中,因此您的CSS应该如下所示:

ul li:nth-child(5) a {
    color: #FFF;
}

我猜
a
在第5个
li
子项中,因此您的CSS应该如下所示:

ul li:nth-child(5) a {
    color: #FFF;
}

您为
a
匹配的方式与某个超链接匹配,该超链接是某个内容的第五个子项。如果要为未排序列表的第5项中的所有超链接上色,则要匹配
ul li:nth child(5)a

ul li:nth-child(5) {
    background-color: #006db6;
    width: 100px;
    margin: 0 auto;
    border-radius: 5px;
}

ul li:nth-child(5) a {
    color: #FFF;
}

您为
a
匹配的方式与某个超链接匹配,该超链接是某个内容的第五个子项。如果要为未排序列表的第5项中的所有超链接上色,则要匹配
ul li:nth child(5)a

ul li:nth-child(5) {
    background-color: #006db6;
    width: 100px;
    margin: 0 auto;
    border-radius: 5px;
}

ul li:nth-child(5) a {
    color: #FFF;
}

你能分享检查该元素的截图吗请分享你的html你能分享检查该元素的截图吗请分享你的html