我在将 css 应用于具有特定类的 li 元素时遇到问题。我想改变那个 li 的背景颜色,但我找不到办法做到这一点。我不确定这是否会改变“父级”,因为我知道 css 无法控制父级。
CSS
.navi ul li { padding:20px; background-color: #00; }
.navi ul li + .current_location { background-color: #FFF; }
or
.navi ul li .current_location { background-color: #FFF; }
//will only change the background color of letters inside, no the li element.
current_location + ul li { background-color: #FFF; }
// will only apply to the children of the li which has class .current_location.
I want to change the li background color where it has class .current_location;
HTML
<nav class="navi">
<ul>
<li>
<a>General Config</a>
</li>
<li class="current_location">
<a>Menu</a>
</li>
<li>
<a>User Level</a>
</li>
<li>
<a>User</a>
</li>
<li>
<a>Tag</a>
</li>
<li>
<a>Log</a>
</li>
</ul>
</nav>
非常感谢您的建议