【发布时间】:2021-01-18 19:18:19
【问题描述】:
当我将鼠标悬停在 box1 上时,我试图更改 box2 的颜色,但它不起作用。请帮助我为什么这不起作用。
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.box1,
.box2 {
width: 100px;
height: 100px;
}
.box1 {
background-color: teal;
/* position:relative; */
}
.box2 {
background-color: tomato;
position: relative;
left: -50px;
}
.box1:hover .box2 {
background-color: green;
}
<div class="box1"></div>
<div class="box2"></div>
【问题讨论】: