禁用特定 div 上的悬停

2022-01-22 00:00:00 hover html css

当我将鼠标悬停在我的#icon div 上时,会出现一张图片.当我从#icon 移开鼠标时,图像消失了.

When I hover over my #icon div, an image appears. When I remove the mouse from #icon the image disappears.

问题

如果我将鼠标悬停在#icon 上,则将鼠标悬停在图像将出现的空间上,图像就会出现.我已经尝试过任何方法,所以我真的希望你能提供帮助.

If I hover over the space where the image will appear if I hover over #icon, the image appears. I've tried anything, so I really hope you can help.

我需要移除 #image-divs

HTML

<div id="box">
    <div id="icons1">
        <div id="image1"></div>
    </div>
    <div id="icons2">
        <div id="image2"></div>
    </div>
    <div id="icons3">
        <div id="image3"></div>
    </div>
    <div id="icons4">
        <div id="image4"></div>
    </div>
</div>

CSS 示例

#box #icons1 #billede1 {
    height: 450px;
    width: 1000px;
    margin-left: -186%;
    margin-top: 150px;
    background-image: url(../html_css/billeder/1.jpeg);
    background-position: center;
    background-size: cover;
    opacity: 0.0;
    transition: opacity 0.5s ease-in-out;
    -moz-transition: opacity 0.5s ease-in-out;
    -webkit-transition: opacity 0.5s ease-in-out;
}

推荐答案

使用pointer-events:none

div{pointer-events:none}
div:hover{color:red;}

<div>Hover over me</div>

相关文章