【发布时间】:2017-07-26 10:38:13
【问题描述】:
有没有办法在悬停两个 div 时以不同的方式影响一个 div? 最好以 CSS 方式了解解决方案,但如果没有 CSS 方式,那么我对 JQuery 或 Javascript 方式持开放态度。
例如,当我将鼠标悬停在 div myData1 上时,我会影响分隔符以具有某种样式。当我将鼠标悬停在 div myData2 上时,我会以任何其他独特的方式影响分隔符。
.myData1{
width: 50px;
height: 50px;
background-color: #444;
}
.myData1:hover + #separator{
width: 50px;
heightL 100px;
background-color: #cba;
}
.myData2{
width: 50px;
height: 50px;
background-color: #888;
}
.myData2:hover + #separator{
width: 50px;
height: 100px;
background-color: #dba;
}
#separator{
width: 50px;
height: 100px;
background-color: #666;
}
<div>
<div class="myData1">
</div>
<div id="separator">
</div>
<div class="myData2">
</div>
</div>
【问题讨论】:
-
我们可以改变div的顺序吗?如果可以的话,CSS 本身就有解决方案,或者我们必须使用 jQuery。
标签: javascript jquery css hover elements