<ul class="promocode">
<li>one</li>
<li>two</li>
<li class="three">three</li>
</ul>
Сan I use :not to create a hover effect on the entire list, but hovering over three
didn’t hover over the entire list?
I don’t seem to fully understand how this thing works. And I couldn’t do it
3
Answers
Yes you can use
:not
for exclude.three li
You can also use it directly to
ul
but you will not able tohover
singleli
You can use
has()
to achieve this:If the requirement is as stated: viz change the background color of the ul when any li except .three is hovered, then this can be done with a pseudo before element.
This snippet sets the ul to position relative and a before pseudo element on hovering any bar the .three lis is set to have the full height and width of the ul with position absolute.
This then carries the background color.
Note: this is not a general purpose selection solution – it is just for the specific requested case of setting a background.