6

前端 | 纯CSS实现无限循环轮播

 2 years ago
source link: https://www.scarsu.com/infinite_scroll_by_css/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

前端 | 纯CSS实现无限循环轮播

无JS代码实现无限循环轮播、鼠标悬浮时暂停动画、鼠标移出时继续动画

2022-04-22 | 10技术 | 前端 | 156 字 | 1 分钟 | 阅读量 200 条评论

demo代码

<div class="wrap">
<div class="slide-dom">
<div class="itemA">A</div>
<div class="itemB">B</div>
<div class="itemA">A</div>
<div class="itemB">B</div>
</div>
</div>


@keyframes infinite-slide {
0% {
transform: translateX(0);
}
100% {
transform: translateX(-50%);
}
}
.wrap{
overflow-x: visible;
background:#eee;
width:200px;
height:300px;
margin:0 auto;
padding:100px 0;
}
.slide-dom{
width:max-content;
animation: infinite-slide 10s linear infinite;
}
/* 鼠标悬浮时暂停动画 */
.slide-dom:hover{
animation-play-state: paused;
}
.itemA{
display:inline-block;
width:200px;
height:100px;
background:pink;
}
.itemB{
display:inline-block;
width:200px;
height:100px;
background:yellow;
}

demo在线地址

preview

回到首页分享
来发评论吧~
Powered By Valine
v1.4.18

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK