需要侧边栏才能正常工作,但是当您将光标移动到 <div id="out_trigger"></div>
的左侧时有效事件警报('光标移出...')。
现在,当您将鼠标悬停在元素 el_1、el_2 上时,会触发该事件。这不应该是这样。
https://jsfiddle.net/vkymqd6h/
已找到解决方案:https://jsfiddle.net/ahpfx551/
最佳答案
试试这个
#out_trigger{
background: red;
width: 50px;
height: 100%;
position: fixed;
left: 0;
top: 0;
background-color: blue;
z-index: 2000;
}
#left_sidebar
{
position: fixed;
z-index: 4000;
top: 160px;
left: 0px;
width: 50px;
/* pointer-events: none; */
}
.item
{
opacity: 0.5;
width: 35px;
height: 30px;
cursor: pointer;
color: white;
background-color: green;
transition: all 0.5s;
padding-top: 15px;
padding-left: 5px;
}
.item:hover{
opacity: 1;
}
#sidebar_trigger{
position: fixed;
left: 0;
top: 0;
width: 5px;
height: 100%;
background-color: red;
z-index: 999;
}
这是jsfiddle
关于javascript - mouseleave 在 block 的交叉点触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40905533/