您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

CSS中是否存在`pointer-events:hoverOnly`或类似的东西?

CSS中是否存在`pointer-events:hoverOnly`或类似的东西?

我认为仅凭CSS不可能实现您的目标。但是,正如其他贡献者所提到的那样,在JQuery中做起来很容易。这是我的操作方法

的HTML

<div id="toplayer" class="layer" style="z-index:20; pointer-events:none; background-color: white; display: none;">Top layer</div><div id="bottomlayer" class="layer" style="z-index:10;">Bottom layer</div>

CSS(不变)

.layer {
    position:absolute;
    top:0px;
    left:0px;
    height:400px;
    width:400px;
}

jQuery查询

$(document).ready(function(){
    $("#bottomlayer").hover(
        function() {
            $("#toplayer").css("display", "block");
        },
        function() {
            $("#toplayer").css("display", "none");
        }
    );
});
CSS 2022/1/1 18:14:19 有492人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶