The problem of hover in css

now there is a nested structure

<style>
  div{ display: inline-block; margin: 50px;}
  .box-3{ width: 200px; height: 200px; background: pink}
  .box-2{ background:rgb(113, 160, 179)}
  .box-1{ background:thistle}
  div:hover{ outline:2px dashed rebeccapurple}
</style>


<div class="box-1">
  <div class="box-2">
    <div class="box-3"></div>
  </div>
</div>

the effect I want to achieve is that the element that passes through will have the hover effect. In fact, when the hover reaches the child element, the parent element will also trigger the hover effect, which is somewhat similar to the bubbling

in js.

clipboard.png

is there a css solution?

Note: js can be implemented without js implementation method. Thank you

here is the js implementation demo
https://codepen.io/xboxyan/pe.

Css
May.22,2021

this is really a little difficult


it is impossible for you to have this html structure.

but you can change the structure, for example:

<div class="box-container">
    <div class="box-1"></div>
    <div class="box-2"></div>
    <div class="box-3"></div>
</div>

then box-1 box-2 box-3 simulates the nesting relationship with various positioning layout methods, and then each adds its own hover effect.

Link description

Doesn't

div:hover {outline:2px dashed rebeccapurple} mean adding a hover effect to all div?
if you want to be specific to each sub-object, you can add a class to it.
examples
div.box-3:hover {outline:2px dashed rebeccapurple}

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b41ca9-2c5a3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b41ca9-2c5a3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?