悬停一个div,但不是悬停在主体外的div,因为位置:绝对 [英] hovering a div, but not hovering a div which is outside the main-div because of position:absolute

查看:127
本文介绍了悬停一个div,但不是悬停在主体外的div,因为位置:绝对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示此取消选择按钮,将鼠标悬停在图片上,但不要将鼠标悬停在图片中的图像下方。 (absolute,bottom:-20px)

I want to show this 'deselect'-button on hovering the image but not on hovering the stars under the image which are in the image-div. (absolute, bottom:-20px)

以下是HTML代码:

<div class="image-wrapper">
 <div class="stars"></div>
 <div class="deselect">deselect</div>
</div>

我不想把星星放在 .image -wrapper

这不起作用:

$('.image-wrapper:not(.stars)').hover(

function () {
    $(this).find(".deselect").show();
},

function () {
    $(this).find(".deselect").hide();
});


推荐答案

尝试添加到您的css:

try to add in your css:

.stars { pointer-events:none;}

这篇关于悬停一个div,但不是悬停在主体外的div,因为位置:绝对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆