0

Example code:

<div class="box1"></div>
<div class="box2"></div>

What I want is hovering on box2 to change the style of box1.

Besides do it this way.

<div class="box2"></div>
<div class="box1"></div>

.box2:hover ~ .box1 {

}  

Is there another solution?

  • try to watch this https://stackoverflow.com/questions/6910049/on-a-css-hover-event-can-i-change-another-divs-styling – Leo Aug 30 '18 at 15:08
  • 1
    Thanks a lot. I will delete this question after reading. – 楊勝翔 Aug 30 '18 at 15:11
  • Leo, I have watched your link. I already know "~" only works for sibling. I just want to know is there a way besides edit html. – 楊勝翔 Aug 30 '18 at 15:20
  • I do not understand, the question is if you want to do it another way than css, ie via js, or another way with respect to html? – Leo Aug 30 '18 at 15:33
  • I want to do it with only css. Instead of editing html and changing the layout. But it seems impossible. – 楊勝翔 Aug 30 '18 at 16:00
  • but what we have suggested is the correct way, how else would you like to do? – Leo Aug 31 '18 at 06:44
  • or you're expressing yourself a little bad, or I'm not understanding a lot – Leo Aug 31 '18 at 06:45

0 Answers0