// If the cube is directly inside the container:
#container:hover > #cube { background-color: yellow; }
// If cube is next to (after containers closing tag) the container:
#container:hover + #cube { background-color: yellow; }
// If the cube is somewhere inside the container:
#container:hover #cube { background-color: yellow; }
// If the cube is a sibling of the container:
#container:hover ~ #cube { background-color: yellow; }
#a:hover ~ #b {
background: #ccc
}
<div id="a">Div A</div>
<div>random other elements</div>
<div>random other elements</div>
<div>random other elements</div>
<div id="b">Div B</div>
#container:hover > #cube { background-color: yellow; }
A child element hover cannot effect a parent class or a class elsewhere in the code besides children and siblings. You'll have to use Javascript for that.
#a:hover + #b {
background: #ccc
}
<div id="a">Div A</div>
<div id="b">Div B</div>
.hover {
background-color: blue;
padding: 8px;
}
.move {
background-color: red;
padding: 8px;
transition: 0.5s;
}
.hover:hover ~ .move {
margin-top: 48px;
}
Code Example |
---|
Css :: one image position relative and other absolute |
Css :: background repeat space |
Css :: vertical hr |
Css :: hover show scrollbar css |
Css :: tabla responsive css |
Css :: css transform translate rotate |
Css :: change element in iframe |
Css :: wrap none css |
Css :: how to make background image fit to screen |
Css :: css border different sides |
Css :: outside padding css |
Css :: css especifico para safari |
Css :: black gradient background effect |
Css :: background-repeat |
Css :: select dropdown icon change |
Css :: how to call media query inside css class |
Css :: move bullets in css |
Css :: add image to div in css |
Css :: focus selector css |
Css :: transform orgin css |
Css :: css no wrap |
Css :: input type password css |
Css :: list decoration none |
Css :: email background image |
Css :: center flex |
Css :: force css style in angular |
Css :: css selctors |
Css :: install tailwind css in react |
Css :: flexbox navbar fixed top |
Css :: onclick after color change in css |