基本上,我制作了一个 3D 轮播,其中包含 3 个图像。当用户单击“下一个”和“上一个”按钮时,轮播会前后移动。我还在顶部有一个单独的图像来产生这种悬停效果。我想将悬停效果添加到轮播中的图像上,具有相同的动画、不透明度、文本、大小等。但是,我不知道如何包含它。我怎样才能做到这一点?任何帮助,将不胜感激。这是我的代码。谢谢。
var carousel = $(".carousel"),
currdeg = 0;
$(".next").on("click", { d: "n" }, rotate);
$(".prev").on("click", { d: "p" }, rotate);
function rotate(e){
if(e.data.d=="n"){
currdeg = currdeg - 120;
}
if(e.data.d=="p"){
currdeg = currdeg + 120;
}
carousel.css({
"-webkit-transform": "rotateY("+currdeg+"deg)",
"-moz-transform": "rotateY("+currdeg+"deg)",
"-o-transform": "rotateY("+currdeg+"deg)",
"transform": "rotateY("+currdeg+"deg)"
});
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="style.css" rel="stylesheet" type="text/css">
<title>Document</title>
</head>
<body>
<div class="content">
<a href="#open-modal">
<div class="content-overlay"></div>
<img class="content-image" src="https://static.independent.co.uk/s3fs-public/thumbnails/image/2014/03/25/12/eiffel.jpg">
<div class="content-details fadeIn-bottom">
<h3 class="content-title">Eiffel Tower</h3>
</div>
</a>
</div>
<div class="container">
<div class="carousel">
<div class="item a"><img src="https://www.insidehook.com/wp-content/uploads/2019/08/HERO-3.jpg?fit=1200%2C750" width="250px" height="200px"></div>
<div class="item b"><img src="https://static.independent.co.uk/s3fs-public/thumbnails/image/2014/03/25/12/eiffel.jpg" width="250px" height="200px"></div>
<div class="item c"><img src="https://nypost.com/wp-content/uploads/sites/2/2019/12/robberies-serious-crimes-spike-in-central-park-this-year.jpg?quality=80&strip=all" width="250px" height="200px"></div>
</div>
</div>
<div class="next">Next</div>
<div class="prev">Prev</div>
<script src="script.js"></script>
</body>
</html>
拉莫斯之舞
相关分类