Quantcast
Channel: Active questions tagged onhover - Stack Overflow
Viewing all articles
Browse latest Browse all 49

Change colour of all elements expect the hovered element using CSS

$
0
0

I am creating a list using HTML and CSS. What I am trying to achieve is all the elements will be black until they are hovered on. When hovered, all elements except the hovered text will change color. I am attaching my code; it would be helpful if anyone could point out the mistake or tell me why it's not working.

.sub-menu-mast {  line-height: 30px;  background-color: rgb(254, 254, 254);  width: 9rem;  cursor: pointer;}.sub-menu-mast>li>a {  color: black;  position: relative;  left: 10%;}.sub-menu-mast a:not(:hover) {  color: red;}
<nav><ul><li><a>XYZ </a><ul class="sub-menu-mast"><li><a href="">Track</a></li><li><a href="">Return</a></li></ul></li></ul></nav>

Viewing all articles
Browse latest Browse all 49

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>