Can I change the color of the envelope icon when the email link is hovered?
.contact-info.box-style2 p a:hover .contact-info.box-style2 .box-icon i {
color: red;
}
/* for demo purposes */
.flaticon-envelope {
display: inline-block;
background: blue;
height: 20px;
width: 20px;
}
<div class="contact-info box-style2 ft-contact-info">
<div class="box-icon"><i class="flaticon-envelope"></i></div>
<p><a href="mailto:[email protected]">[email protected]</a></p>
</div>
2
Answers
Sure can. Though for your case, you’ll need to adjust the icon and text order in the DOM and swap them visually.
There is a next sibling selector that is the
+
. So if you use.contact-info p:hover + .box-icon i
you can change the color, as long as the item comes next in the DOM.If my understanding is correct. You want to change the background color of the box when hovering the link.
If that so, you can use has() selector in css.
Edit: As suggested by @Tim R