The css selector $parent > $immediateChild is not working for nested lists.
Only the direct <li>
of the level-1 list should be red, but the selector selects all <li>
in all nested lists.
ul.level-1 > li
{
color: red;
}
<ul class="level-1">
<li>Level 1
<ul>
<li>Level 2</li>
</ul>
</li>
</ul>
Also found this post and it states that the second <ul>
needs to be in the <li>
of the first to have valid html. I did that but it's not working.
/EDIT: I just transformed my nested list to <div>
s instead like before. It's a menu with a submenu and sub-submenu. The nested list is hard to address via CSS and there were also issues with my flexbox submenu.
So, I can't recommend doing menus with a (nested) list because all styles are natively inherited to all childs which is probably not what you want. The accepted answer would solve this particular problem, though.