【发布时间】:2021-05-07 19:37:47
【问题描述】:
https://twitter.com/P_h_l_i_x/status/1353659923834544128
通过上面的链接,我正在尝试复制本页面“影响者”部分中的整个过渡和动画,我对此的思考过程并没有为我提供任何解决方案。任何想法和可能的解决方案将不胜感激。谢谢大家
const images = document.querySelectorAll(".cycle");
console.log(images.length);
function cycle() {
for (let i = 0; i < images.length; i++) {
if (images[i].classList.contains("active")) {
images[i].classList.remove("active");
// console.log(images[i]);
const newActive = i + 1 >= images.length ? 0 : i + 1;
// console.log(newActive);
images[newActive].classList.add("active");
// console.log(newActive);
break;
// continue;
}
}
}
document.addEventListener("DOMContentLoaded", () => setInterval(cycle, 500));
header {
position: relative;
height: 90px;
// overflow: hidden;
width: 90px;
.image1 {
position: absolute;
width: 23.5rem;
height: 27.5rem;
top: 0.125rem;
left: 0.1875rem;
z-index: 0;
background: #5a9f45;
box-shadow: rgba(134, 198, 116, 0.1);
// transform: rotate(-8deg);
transition: all 0.2s linear;
}
.image2 {
position: absolute;
width: 23.5rem;
height: 27.5rem;
top: 0.125rem;
left: 0.1875rem;
z-index: -10;
background: #5a9f45;
box-shadow: rgba(134, 198, 116, 0.1);
// transform: rotate(-8deg);
transition: all 0.2s linear;
}
.image3 {
position: absolute;
width: 23.5rem;
height: 27.5rem;
top: 0.125rem;
left: 0.1875rem;
z-index: -20;
background: #5a9f45;
box-shadow: rgba(134, 198, 116, 0.1);
// transform: rotate(-8deg);
transition: all 0.2s linear;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<!-- Comment here -->
<body>
<img src="./assets/desktop/Icon feather-instagram.svg" alt="" />
<div class="for"></div>
<h1 class="links">Hesgoal</h1>
<div class="header">
<img src="http://placekitten.com/200/300" alt="" class="image1 img" />
<img src="http://placekitten.com/200/300" alt="" class="image2 img" />
<img src="http://placekitten.com/200/300" alt="" class="image3" />
</div>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js"></script> -->
</body>
</html>
【问题讨论】:
-
我给你做了一个sn-p。请将其设为minimal reproducible example。您可以从 lorem kitten 或 placeholder.com 获取图片
-
我已经添加了图片,请您指出正确的方向@mplungjan
标签: javascript css-transitions anime.js