<div class="container">
<div>
<img src="https://tuchuang.xgr.cab/xgr/2023/11/08/654b82c1b3d9f.jpg?img=1" alt="" />
<h3>头像1</h3>
<p>头像1</p>
</div>
<div>
<img src="https://tuchuang.xgr.cab/xgr/2023/11/08/654b82c1b3d9f.jpg?img=2" alt="" />
<h3>头像2</h3>
<p>头像2</p>
</div>
<div>
<img src="https://tuchuang.xgr.cab/xgr/2023/11/08/654b82c1b3d9f.jpg?img=3" alt="" />
<h3>头像3</h3>
<p>头像3</p>
</div>
<div>
<img src="https://tuchuang.xgr.cab/xgr/2023/11/08/654b82c1b3d9f.jpg?img=4" alt="" />
<h3>头像4</h3>
<p>头像4</p>
</div>
<div>
<img src="https://tuchuang.xgr.cab/xgr/2023/11/08/654b82c1b3d9f.jpg?img=5" alt="" />
<h3>头像5</h3>
<p>头像5</p>
</div>
<div>
<img src="https://tuchuang.xgr.cab/xgr/2023/11/08/654b82c1b3d9f.jpg?img=6" alt="" />
<h3>头像6</h3>
<p>头像6 </p>
</div>
</div>
{/tabs-pane}
{tabs-pane label="css"}
/* number of elements */
.container {
--d: 15s; /* duration */
display: grid;
grid-template-columns: repeat(3, 300px); /* number of visible elements + width */
overflow: hidden;
-webkit-mask: linear-gradient(90deg, rgba(0, 0, 0, 0), #000 5% 95%, rgba(0, 0, 0, 0));
}
.container > div {
grid-area: 1/1;
display: grid;
grid-template-columns: 120px 1fr;
align-content: center;
gap: 10px;
background: #fff padding-box;
border-inline: 10px solid rgba(0, 0, 0, 0);
animation: r var(--d) linear infinite;
}
.container > div img {
width: 100%;
grid-row: span 2;
}
.container > div * {
margin: 0;
}
.container > div h3 {
margin-top: auto;
}
.container > div:nth-child(2) {
animation-delay: calc(-0.1666666667 * var(--d));
}
.container > div:nth-child(3) {
animation-delay: calc(-0.3333333333 * var(--d));
}
.container > div:nth-child(4) {
animation-delay: calc(-0.5 * var(--d));
}
.container > div:nth-child(5) {
animation-delay: calc(-0.6666666667 * var(--d));
}
.container > div:nth-child(6) {
animation-delay: calc(-0.8333333333 * var(--d));
}
@keyframes r {
16.6666666667% {
transform: translate(-100%);
}
16.6766666667% {
transform: translate(500%);
}
}
body {
margin: 0;
min-height: 100vh;
display: grid;
place-content: center;
font-family: system-ui;
background: #fffefe;
}
{/tabs-pane}
代码来自CodePen无限滚动动画
评语 (0)