How to use pure CSS3 to achieve the effect of image carousel

不言
Release: 2018-08-22 14:56:15
Original
4286 people have browsed it

The content of this article is about how to use pure CSS3 to achieve the effect of image carousel. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<style type="text/css">
*{ 
    margin: 0;
    padding: 0; 
    text-decoration: none;
}
ul{
    list-style: none;
}
ul li{
    width: 400px;
    height:200px;
}
#container{
    position: relative;
    width: 400px;
    height: 200px;
    overflow: hidden;/*隐藏溢出的图片*/
}
.pic{
    width:1600px;/*4张图的宽度*/
    position: absolute;/*基于父容器进行定位*/
    left:0;
    animation-name: carousel;
    animation-duration: 12s;
    animation-iteration-count: infinite;/*//动画调用可以简写*/
}
@keyframes carousel {
    0%,30%{
        left: 0;
    }
    35%,65%{
        left: -400px;
    }
    70%,99%{
        left: -800px;
    }
    100%{
        left: -1200px;
    }   
}
.pic li{
    float: left;
    background: #5dd94e;
}
.pic li img {
    width: 400px;
    height: 200px;
}
</style>
<body>
<p id="container">
    <ul class="pic">
        <li><a href="javascript:;">111</a></li>
        <li><a href="javascript:;">222</a></li>
        <li><a href="javascript:;">333</a></li>
        <li><a href="javascript:;">111</a></li><!-- 克隆第一张 -->
    </ul>        
</p>   
</body>
</html>
Copy after login

Related recommendations:

How to make images rotate continuously in css3? [Detailed explanation]

How to use css to set the background color of text? Detailed explanation of css background color code

The above is the detailed content of How to use pure CSS3 to achieve the effect of image carousel. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template