我需要帮助在下面的脚本中添加相当于.mouseLeave
的触摸功能,这样悬停效果就会消失。
<figure class="snip1554">
<img src=https://ae01.alicdn.com/kf/HTB1Jgc1bCFRMKJjy0Fhq6x.xpXao/FOCALLURE-18-Colors-Glitter-Eye-Shadow-Cosmetic-Makeup-Diamond-Lips-Loose-Makeup-Eyes-Pigment-Powder.jpg />
<figcaption>
<h3>Let them lose themselves in your eyes</h3>
</figcaption>
<a href="#"></a>
</figure>
<style>
@import url(https://fonts.googleapis.com/css?family=Poppins:700;);
.snip1554 {
background-color: #045e78;
color: #ffffff;
display: inline-block;
font-family: 'Poppins', sans-serif;
font-size: 16px;
margin: 0px;
max-width: 315px;
min-width: 230px;
overflow: hidden;
position: relative;
text-align: left;
width: 100%;
}
.snip1554 * {
-webkit-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition: all 0.45s ease;
transition: all 0.45s ease;
}
.snip1554:after {
background-color: white;
opacity: 0.6;
top: 0;
bottom: 0;
content: '';
left: -100%;
position: absolute;
width: 100%;
box-shadow: 0 0 100px white;
-webkit-transform: skew(-20deg);
transform: skew(-20deg);
-webkit-transition: all 0.6s ease;
transition: all 0.6s ease;
}
.snip1554 img {
vertical-align: top;
max-width: 100%;
backface-visibility: hidden;
}
.snip1554 figcaption {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1;
line-height: 1em;
opacity: 0;
}
.snip1554 h3 {
position: absolute;
left: 0px;
bottom: 10px;
font-size: 1em;
font-weight: 400;
line-height: 1.1em;
margin: 0;
text-transform: uppercase;
}
.snip1554 h3 span {
font-weight: 100;
}
.snip1554 a {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1;
}
.snip1554:hover > img,
.snip1554.hover > img {
opacity: 0.4;
-webkit-filter: grayscale(100%);
filter: grayscale(100%);
}
.snip1554:hover:after,
.snip1554.hover:after {
left: 200%;
}
.snip1554:hover figcaption,
.snip1554.hover figcaption {
opacity: 1;
}
</style>
<script>
$(".hover").mouseleave(
function () {
$(this).removeClass("hover");
}
;
}
);
</script>
我正在谈论的代码在本段上方的脚本中。我需要触摸设备的东西,以便移除悬停效果,而不仅仅是停留。
答案 0 :(得分:0)
您可以使用 touchend()(类似于mouseLeave)...
https://developer.mozilla.org/en-US/docs/Web/Events/touchend
您也可以为此添加相同的悬停类... 但是你需要首先获得 useragent ...
if(navigator.userAgent.match(/(Android|iPod|iPhone|iPad|IEMobile|BlackBerry|Opera Mini)/)){
$('body').on('touchend','your element', function(){
// something to trigger transition
});
}
&#13;