<div class="iteye-blog-content-contain" style="font-size: 14px;">
<pre name="code" class="html"><!DOCTYPE html>
<html>
<head> ;
<title> Feitian Net Things--Pure CSS Code to Realize Image Carousel</title>
<meta charset="utf-8" />
<meta name="description" content="Feitian Net Things, WEB front-end development, pure css3 code picture carousel, HTML5+CSS3 wonderful case" />
<meta name="keywords" content="Feitian.com, WEB front-end development, HTML5, CSS3, jQuery," />
< ;meta name="author" content="R.tian @eduppp.cn 2015">
<link rel="shortcut icon" href="http://eduppp.cn/images/logo4. gif" />
<link rel="apple-touch-icon" href="http://eduppp.cn/images/logo.gif" />
<style type="text/css">
#frame {/*----------picture carousel photo frame container----------*/
position: absolute; /*--absolute positioning, convenient for the positioning of child elements*/
width: 300px;
height: 200px;
overflow: hidden;/*--picture frame function, only one picture is displayed---*/
border-radius:5px;
}
#dis {/*--absolute positioning is convenient for automatic automatic picture introduction Distribution positioning---*/
position: absolute;
left: -50px;
top: -10px;
opacity: 0.5;
}
#dis li {
display: inline-block;
width: 200px;
height: 20px;
margin: 0 50px;
float : left;
text-align: center;
color: #fff;
border-radius: 10px;
background: #000;
}
#photos img {
float: left;
width:300px;
height:200px;
}
#photos {/*---set the total The width of the picture--the carousel effect is achieved by displacement----*/
position: absolute;z-index:9;
width: calc(300px * 5);/*---If you want to modify the number of pictures, you need to modify the following Animation parameters*/
}
.play{
animation: ma 20s ease-out infinite alternate;/**/
}
@keyframes ma {/*---There are two stages of each picture switching: displacement switching and static. The effect in the middle can be customized arbitrarily----*/
0%,20% { margin-left: 0px; }
25%,40% { margin-left: -300px; }
45%,60% { margin-left: -600px; }
65%,80% { margin-left: -900px; }
85%,100% { margin-left: -1200px; }
}
.num{
position:absolute;z-index:10;
display:inline-block;
right:10px;top:165px;
border-radius:100%;
background:#f00;
width:25px;height:25px;
line-height:25px;
cursor:pointer;
color:#fff;
text-align:center;
opacity:0.8;
}
.num:hover{background:#00f;}
.num:hover,#photos:hover{animation-play-state:paused;}
.num:nth-child(2){margin-right:30px}
.num:nth-child(3){margin-right:60px}
.num:nth-child(4){margin-right:90px}
.num:nth-child(5){margin-right:120px}
#a1:hover ~ #photos{animation: ma1 .5s ease-out forwards;}
#a2:hover ~ #photos{animation: ma2 .5s ease-out forwards;}
#a3:hover ~ #photos{animation: ma3 .5s ease-out forwards;}
#a4:hover ~ #photos{animation: ma4 .5s ease-out forwards;}
#a5:hover ~ #photos {animation: ma5 .5s ease-out forwards;}
@keyframes ma1 {0%{margin-left:-1200px;}100%{margin-left:-0px;} }
@keyframes ma2 {0%{margin-left:-1200px;}100%{margin-left:-300px;} }
@keyframes ma3 {100%{margin-left:-600px;} }
@keyframes ma4 {100%{margin-left:-900px;} }
@keyframes ma5 {100%{margin-left:-1200px;} }
</style>
</head>
<body>
<div id="frame" >
<a id="a1" class="num">1</a>
<a id="a2" class="num">2</a>
<a id="a3" class="num">3</a>
<a id="a4"class="num">4</a>
<a id="a5" class="num">5</a>
<div id="photos" class="play">
<img src="http://eduppp.cn/images/0/1.jpg" >
<img src="http://eduppp.cn/images/0/3.jpg" >
< img src="http://eduppp.cn/images/0/4.jpg" >
<img src="http://eduppp.cn/images/0/5.jpg" >
<img src ="http://eduppp.cn/images/0/2.jpg" >
<ul id="dis">
<li>Chinese landmarks: see </li>
<li> Landmarks in China: Information </li>
<li> Landmarks in China: An An</li>
<li> Landmarks in China: Renren</li>
<li> Landmarks in China :quote </li>
</ul>
</div>
</div>
</body>
</html></pre>
<p> </p>
</div>
pure css carousel (focus)
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326457364&siteId=291194637
Recommended
Ranking