Categories
CSS

How to use :hover to modify the CSS of another class?

Spread the love

Sometimes, we want to use :hover to modify the CSS of another class.

In this article, we’ll look at how to use :hover to modify the CSS of another class.

How to use :hover to modify the CSS of another class?

To use :hover to modify the CSS of another class, we can use it with another selector.

For instance, we write

.item:hover .wrapper {
  color: #fff;
  background-color: #000;
}

to select the elements with the class wrapper in the elements with class item that we hovered on.

We set its color and background-color for those elements.

Conclusion

To use :hover to modify the CSS of another class, we can use it with another selector.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *