gpt4 book ai didi

jquery - 在信息图标悬停时翻转卡片 - Tweenmax

转载 作者:行者123 更新时间:2023-11-28 02:53:27 25 4
gpt4 key购买 nike

这是我的 fiddle :DEMO

将鼠标悬停在卡片上会翻转卡片。如何在悬停在“信息”图标上时翻转卡片?

$(".cardWrapper").hover(
function() {
TweenLite.to($(this).find(".card"), 1.2, {
rotationY: 180,
ease: Back.easeOut
});
},
function() {
TweenLite.to($(this).find(".card"), 1.2, {
rotationY: 0,
ease: Back.easeOut
});
}
);

最佳答案

要完成这项工作,您需要将选择器更改为 .cardWrapper .info 并将 find() 更改为 closest()

您还必须将悬停进/出事件分开,否则翻转将立即发生,因为 .info 在翻转时不再“悬停”。像这样:

$(".cardWrapper .info").mouseenter(function() {
TweenLite.to($(this).closest(".card"), 1.2, {
rotationY: 180,
ease: Back.easeOut
});
});

$(".cardWrapper").mouseleave(function() {
TweenLite.to($(this).find(".card"), 1.2, {
rotationY: 0,
ease: Back.easeOut
});
});

TweenLite.set(".cardWrapper", {
perspective: 800
});
TweenLite.set(".card", {
transformStyle: "preserve-3d"
});
TweenLite.set(".back", {
rotationY: -180
});
TweenLite.set([".back", ".front"], {
backfaceVisibility: "hidden"
});

$(".cardWrapper .info").mouseenter(function() {
TweenLite.to($(this).closest(".card"), 1.2, {
rotationY: 180,
ease: Back.easeOut
});
});

$(".cardWrapper").mouseleave(function() {
TweenLite.to($(this).find(".card"), 1.2, {
rotationY: 0,
ease: Back.easeOut
});
});


TweenMax.staggerTo($(".card"), 1, {
rotationY: -180,
repeat: 1,
yoyo: true
}, 0.1);
body {
background-color: black;
margin: 20px;
font-family: Arial, sans-serif;
}

.cardWrapper {
width: 200px;
height: 200px;
position: relative;
/*background-color:#333;*/
float: left;
margin-right: 10px;
cursor: pointer;
-webkit-font-smoothing: antialiased;
}

.cardFace {
position: absolute;
width: 200px;
height: 200px;
overflow: hidden;
}

.front {
background-color: #333;
}

.back {
background-color: #333;
}

.cardFace h1 {
margin: 0px;
font-size: 30px;
padding: 10px 0px 10px 10px;
border-bottom: solid 6px #aaa;
border-top: solid 6px #aaa;
background-color: black;
color: white;
}

.cardFace.back h1 {
border-color: #91e600;
}

.moreInfo {
padding: 10px;
color: white;
line-height: 24px;
}

.info {
font-size: 24px;
color: #fff;
font-weight: bold;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.4/TweenMax.min.js"></script>
<div class="cardWrapper">
<div class="card">
<div class="cardFace front">
<h1>front</h1>
<div class="info">&#9432;</div>
</div>
<div class="cardFace back">
<h1>back</h1>
</div>
</div>
</div>

<div class="cardWrapper">
<div class="card">
<div class="cardFace front">
<h1>front</h1>
<div class="info">&#9432;</div>
</div>
<div class="cardFace back">
<h1>back</h1>
</div>
</div>
</div>

<div class="cardWrapper">
<div class="card">
<div class="cardFace front"><img src="https://s.cdpn.io/16327/logo_texture.jpg"></div>
<div class="cardFace back"><img src="https://s.cdpn.io/16327/logo_robust.jpg"></div>
</div>
</div>

<div class="cardWrapper">
<div class="card">
<div class="cardFace front">
<h1>front</h1>
<div class="info">&#9432;</div>
</div>
<div class="cardFace back">
<h1>back</h1>
</div>
</div>
</div>

<div class="cardWrapper">
<div class="card">
<div class="cardFace front">
<h1>front</h1>
<div class="info">&#9432;</div>
</div>
<div class="cardFace back">
<div class="moreInfo">This is just an example of how you can customize the content of any card face.</div>
</div>
</div>
</div>

关于jquery - 在信息图标悬停时翻转卡片 - Tweenmax,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46562941/

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