can a div change an item in another div css

49

/*You can only go to the immediately next sibling (with +) or to any next sibling (with ~).
It is not possible to go up the HTML tree (to the parent). So it would be possible to go
from a hover over .beta to a child of .alpha, if you switch the their position in the HTML DOM
(.beta before .alpha). So, see this example:*/

/*Css*/

.alpha {
  position:relative;
  background-color:red;
  width:100px;
  height:50px;
}

.alpha .more {
  position:absolute;
  top:40%;
  left:40%;
  display:none
}

.beta {}

.beta:hover + .alpha .more {
  display:block;
}

/*Html*/

<div class="beta">
  <h3>Make hover</h3>
</div>

<div class="alpha">
  <span class="more">Hello</span>
</div>

Comments

Submit
0 Comments