Css 无法更改<;a>;字体颜色
我无法更改菜单中的第五个元素。它应该有蓝色的背景(它的作品),但我不能改变字体颜色为白色 CSSCss 无法更改<;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>
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