Click here to Skip to main content
16,021,125 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I know when in your CSS you write section:hover {} all of the things inside the curly brackets will apply to the "section"

Is there a way to impact a different part of your html like for example if I wanted a text to disappear maybe I would write "(text) display:0;"

If it is possible to have a different element be impacted I would like to know how you get that done.

Thanks. 
Matt


What I have tried:

Searched all over with no luck.
Posted
Updated 24-Oct-19 6:47am

1 solution

It depends on how the other element is related to the section.

If it's a descendant element, you can write:
CSS
section:hover your-element-selector { display: none; }

If it's a sibling element which follows the section, you can write:
CSS
section:hover ~ your-element-selector { display: none; }

If it's somewhere else in the document, then you'll have to use Javascript.

Descendant combinator - CSS: Cascading Style Sheets | MDN[^]
General sibling combinator - CSS: Cascading Style Sheets | MDN[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900