Is there a way to alter styles of a sibling element on hover using only CSS?
I attempted something similar but was unsuccessful.
HTML:
<ul>
<li class="item active">name1</li>
<li class="item">name2</li>
<li class="item">name3</li>
<li class="item">name4</li>
</ul>
SCSS
ul {
padding: 0;
margin: 0;
li {
cursor: pointer;
list-style: none;
padding: 12px 16px;
&.active {
background-color: $primary-blue;
color: white;
}
&:hover {
background-color: $primary-blue;
color: white;
~ .active {
background-color: white !important;
color: black !important;
}
}
}
}
I am attempting to change the style of elements on hover while simultaneously removing the style of the currently active element. The active element could be any position in the list, up to 10 elements. This example has been simplified for clarity.
EDIT! IMPORTANT! I have noticed some confusion regarding my request, I hope this plunker will help clarify things :)