Reputation: 11
I have a structure like this :
HTML
.ba, .ca {
color:black;
size:2rem;
}
.ba:hover {
color:red;
size:2.5rem;
}
.ca:hover {
color:blue;
}
<section class="a">
<div class="b">
<h1 class="ba">Hallo</h1>
</div>
<div class="c">
<p class="ca">Help</p>
</div>
</section>
how do I activate the hover of each element simultaneously when the cursor touches any part of the section?
Upvotes: 0
Views: 71
Reputation: 1
<style>
.ba, .ca {
color:black;
size:2rem;
}
.ba:hover {
color:red;
size:2.5rem;
}
.ca:hover {
color:blue;
}
section:hover .ba{
color:red;
size:2.5rem;
}
section:hover .ca{
color:blue;
}
</style>
<section class="a">
<div class="b">
<h1 class="ba">Hallo</h1>
</div>
<div class="c">
<p class="ca">Help</p>
</div>
</section>
Upvotes: 0
Reputation: 1460
You should add hover
to parent that will affect the children.
Like so -
.ba,
.ca {
color: black;
size: 2rem;
}
.a:hover .ba {
color: red;
size: 2.5rem;
}
.a:hover .ca {
background-color: lightblue;
color: #fff;
}
<section class="a">
<div class="b">
<h1 class="ba">Hallo</h1>
</div>
<div class="c">
<p class="ca">Help</p>
</div>
</section>
Upvotes: 1