Is it possible to change the Background of body or parent div while hover a child div ?
How to change the background color of a parent div or the body part while hovering the text in a child div.
Give me the solution for this
.
.
Is it possible to change the Background of body or parent div while hover a child div ?
How to change the background color of a parent div or the body part while hovering the text in a child div.
Give me the solution for this
.
.
3
Answers
You should use
:has
for this.Yes, it is possible to change the background color of a parent div or the body while hovering over a child div using CSS.
You can achieve this by utilizing the CSS selector known as the "sibling selector" or "general sibling combinator.
In this example, when you hover over the text inside the child div, it will change the background color of the parent div (
.parent
) and the body.The child div is used as the trigger for changing the background color of the parent div and the body.
You can use
:has()
selector but it has limited browser support