gpt4 book ai didi

html - 在多个元素上触发悬停

转载 作者:太空宇宙 更新时间:2023-11-03 21:44:20 25 4
gpt4 key购买 nike

#red, #blue {
position: absolute;
width: 100px;
height: 100px;
}
div:hover {
background-color: yellow !important;
}
#red {
background-color: red;
}
#blue {
background-color: blue;
top: 50px;
left: 50px;
}


<div id="red"></div>
<div id="blue"></div>

是否可以在不使用 javascript 的情况下在光标下的多个元素上触发悬停事件?如何在 this simple example 中将两个方 block 设为黄色?

最佳答案

Pretty little demo

好吧,所有这些答案都只是SWELL,所以我把我的答案扔进去只是为了kicks n giggles

把它们裹在毯子里。将鼠标悬停在毯子上,两者都会变为黄色。

HTML

<div id="wrap">
<div id="red"></div>
<div id="blue"></div>
</div>

CSS

#red, #blue {
position: absolute;
width: 100px;
height: 100px;
}
#red {
background-color: red;
}
#blue {
background-color: blue;
top: 50px;
left: 50px;
}
#wrap:hover > div {
background-color: yellow !important;
}

关于html - 在多个元素上触发悬停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21473930/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com