gpt4 book ai didi

html - 鼠标悬停激活另一个 div

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

我得到了这两个 div。

我需要第二个 div(蓝色)在第一个 div(红色)悬停时弹出它被激活,现在只有当指针触摸隐藏的第二个 div 时它才会出现。

http://codepen.io/IvanPalma/pen/XXpwoW?editors=110

.first-div { 
background-color: red;
height: 300px;
width: 300px;
}

.second-div {
background-color: blue;
height: 200px;
width: 100px;
position: absolute;
left: 250px;
opacity:0;
}
.second-div {
background-color: blue;
height: 200px;
width: 100px;
position: absolute;
left: 250px;
opacity:0;
}

.second-div:hover {
opacity:1;
}
<div class="first-div">
<div class="second-div">
</div>
</div>

最佳答案

将您的最后一个选择器更改为:

.first-div:hover > .second-div {
opacity:1;
}

.first-div { 
background-color: red;
height: 300px;
width: 300px;
}

.second-div {
background-color: blue;
height: 200px;
width: 100px;
position: absolute;
left: 250px;
opacity:0;
}
.second-div {
background-color: blue;
height: 200px;
width: 100px;
position: absolute;
left: 250px;
opacity:0;
}

.first-div:hover > .second-div {
opacity:1;
}
<div class="first-div">
<div class="second-div">
</div>
</div>

关于html - 鼠标悬停激活另一个 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34600516/

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