gpt4 book ai didi

javascript - 删除 :before attribute on hover

转载 作者:行者123 更新时间:2023-11-30 12:42:49 26 4
gpt4 key购买 nike

我在我的图像上有一个类,并通过 .images:before 在其上放置了一个叠加层。现在我想(例如使用 jquery),删除悬停时的覆盖...

这是我认为但不起作用的方法:

$(document).ready(function(){
$('.images').hover(function (){
$(this).css('background','');
});
});

这是 css...

    .image {
position: relative;
display: inline-block;
}

.image:before {
content: '';
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: url('images/overlay.png');
}

任何帮助将不胜感激

最佳答案

您可以将伪选择器与伪元素结合使用:

.image {
position: relative;
display: inline-block;
}

.image:before {
content: '';
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: url('images/overlay.png');
}

.image:hover:before {
display : none;
}

fiddle :http://jsfiddle.net/Re9bj/17/

关于javascript - 删除 :before attribute on hover,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23793639/

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