when I hover over "Div2", I want the hover of "Div1" to work
.Div1:hover{ background:red; }
<div class="Div1">Hello!</div> <div class="Div2">Open hello!</div>
You can choose one class for both to make hoover works for both.
.DivHoover:hover{ background:red; }
<div class="Div1 DivHoover">Hello!</div> <div class="Div1 DivHoover">Open hello!</div>
You can use display: flex on the container, then change the rendering order. Then you can hover on div2 and highlight div1.
.container {
display: flex;
flex-wrap: wrap;
}
.div1, .div2 {
flex: 0 0 100%;
}
.div1 { order: 1; }
.div2 { order: 2; }
.div2:hover ~ .div1 {
background-color: red;
}
<div class="container">
<div class="div2">hello!</div>
<div class="div1">open hello!</div>
</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.