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>
Related recommendations:
How to make images rotate continuously in css3? [Detailed explanation]
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!