纯CSS3的图片slider

本文介绍了一种使用CSS动画实现的图片轮播效果,通过设置不同的动画延迟实现了四张图片的循环显示,并在鼠标悬停时暂停动画。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


<div class="container">
<img class='photo' src="http://farm9.staticflickr.com/8320/8035372009_7075c719d9.jpg" alt="" />
<img class='photo' src="http://farm9.staticflickr.com/8517/8562729616_35b1384aa1.jpg" alt="" />
<img class='photo' src="http://farm9.staticflickr.com/8465/8113424031_72048dd887.jpg" alt="" />
<img class='photo' src="http://farm9.staticflickr.com/8241/8562523343_9bb49b7b7b.jpg" alt="" />

</div>

<style>
body{background:#000;}
.container{
margin:50px auto;
width:500px;
height:300px;
overflow:hidden;
border:10px solid;
border-top-color:#856036;
border-left-color:#5d4426;
border-bottom-color:#856036;
border-right-color:#5d4426;
position:relative;

}
.photo{
position:absolute;
animation:round 16s infinite;
opacity:0;

}
@keyframes round{
15%{opacity:1;}
25%{opacity:1;}
40%{opacity:0;}
}
.container:hover .photo{
animation-play-state:paused;
}

img:nth-child(1){animation-delay:0s;}
img:nth-child(2){animation-delay:4s;}
img:nth-child(3){animation-delay:8s;}
img:nth-child(4){animation-delay:12s;}

</style>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值