Effect How to - Hover on other element to change the background myself








Question

We would like to know how to hover on other element to change the background myself.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.a:hover + .b {<!-- w  ww . j av  a2s.  co  m-->
  font-weight: 700;
}

.a:hover ~ div {
  background: lightgreen;
}
</style>
</head>
<body>
  <div class="a">aaa</div>
  <div class="b">bbb</div>
  <div class="c">ccc</div>
</body>
</html>

The code above is rendered as follows: