Change span opacity within div: hover
I would like to change the opacity spaninside awhen divall this is inside.
HTML:
<div id="about">
<a style="text-decoration: none;" href="/about"><h1>ABOUT ME</h1><br><span class="hover-text">test</span></a>
</div>
CSS
.hover-text {
opacity: 0;
}
#about:hover {
change .hover-text opacity to 1
}
Is it possible to do this with pure CSS?
+4
8 answers
it only works with a child.
Eg . the class of the class has a child range, then it will work
.about:hover .hover-text {
opacity: 0;
}
.about{
border:1px solid black;
}
.hover-text{
opacity: 0;
font-size:30px;
}
.about:hover .hover-text {
opacity: 1;
}<div class="about">
<a style="text-decoration: none;" href="/about"><h1>ABOUT ME</h1><br><span class="hover-text">test</span></a>
</div>
CSS:+4