css:hover state changes the use of another element's style

css:hover state changes the use of another element's style

: When the hover element and the element that needs to change the style are in a parent-child relationship, it can be written like this. father :hover  .son{ plus the element that needs to be changed }

At this time, it is the hover  div1 container, and the background color of the div2 box is changed, but it is found that the relationship between div1 and div2 is not a parent-child relationship but a sibling relationship. At this time, writing this ( . div1 :hover  . div 2 {background: #000; }) does not work. . It should be written as (. div1 :hover + . div2 {background:#f00;})

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324457513&siteId=291194637