纯css3animation写一个轮播图

纯css动画写一个轮播图

直接上代码

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>css动画写轮播图</title>
		<style>
			ul,li{
				list-style: none;
			}
			.box{
				width: 440px;
				height: 220px;
				float: left;
				position: relative;
				overflow: hidden;
			}
			.box1{
				width: 440px;
				height: 220px;
				position: absolute;
				animation: cda 20s ;
				animation-iteration-count: infinite;/*动画无限次播放*/
				animation-timing-function:linear;/*动画速度相同*/
			}
			@keyframes cda{
				0%{left:0px;}
				19.5%{left:0px;}
				20%{left: -440px;}
				39.5%{left: -440px;}
				40%{left: -880px;}
				59.5%{left: -880px;}
				60%{left: -1320px;}
				79.5%{left: -1320px;}
				80%{left: -1760px;}
				99.5%{left: -1760px;}
				100%{left: 0px;}
			}
			.box img{
				width: 440px;
				height: 220px;
				position: relative;
			}
			.box img:nth-child(7){
				position: absolute;
				top: 0px;
				left: 440px;
			}
			.box img:nth-child(8){
				position: absolute;
				top: 0px;
				left: 880px;
			}
			.box img:nth-child(9){
				position: absolute;
				top: 0px;
				left: 1320px;
			}
			.box img:nth-child(10){
				position: absolute;
				top: 0px;
				left: 1760px;
			}
			.dot{
				width:170px;
				height: 18px;
				position: absolute;
				bottom:30px;
				right: 160px;
			}
			.dot li{
				width: 18px;
				height: 18px;
				float: left;
				background:url(images/icons.png);/*本地文件,自行修改*/
				background-position: -855px -790px;
				border-radius: 50%;
				margin-left: 8px;
			}
			.dot li:hover{
				background:url(images/icons.png);/*本地文件,自行修改*/
				background-position: -919px -790px;
			}
			.box1 span{
				display: block;
				width: 18px;
				height: 18px;
				background:url(images/icons.png);/*本地文件,自行修改*/
				background-position: -855px -727px;
				position: absolute;
				bottom: 14px;
				border-radius: 50%;
				z-index: 9;
			}
			.box1 span:nth-child(1){
				right: 263px;
			}
			.box1 span:nth-child(2){
				right: -201px;
			}
			.box1 span:nth-child(3){
				right:-667px;
			}
			.box1 span:nth-child(4){
				right:-1137px;
			}
			.box1 span:nth-child(5){
				right:-1601px;
			}
		</style>
	</head>
	<body>
		<div class="box">
			<div class="box1">
				<span></span>
				<span></span>
				<span></span>
				<span></span>
				<span></span>
				<img src="https://dwz.cn/sUtCMJQ1">
				<img src="https://dwz.cn/nHUED9QQ">
				<img src="https://dwz.cn/Xn4PsM8o">
				<img src="https://dwz.cn/gD0KCPfj">
				<img src="https://dwz.cn/avDOtr3h">
			</div>
			<div class="dot">
				<ul>
					<li></li>
					<li></li>
					<li></li>
					<li></li>
					<li></li>
				</ul>
			</div>
		</div>
	</body>
</html>

效果图如下:
在这里插入图片描述
图片中间的小图标我是用了B站的图标,可以自行修改。

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值