CSS3实现轮播图效果

8 篇文章 0 订阅

因为CSS的局限性,所以只能做出图片无限循环播放的效果,和图片点击链接
其他的因为效果不完美所以摒弃了

效果图预览:

这里写图片描述

代码如下:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            *{
                margin: 0;
                padding: 0;
            }
            ul,li{
                list-style: none;
            }
            .container{
                margin: 0 auto;
                width: 300px;
                height: 300px;
                position: relative;
                overflow: hidden;
            }
            .img_container{
                position: absolute;
                width: 1500px;
                animation:mycolor 10s;
                -moz-animation:mycolor 10s; 
                -webkit-animation:mycolor 10s; 
                -o-animation:mycolor 10s; 
                animation-iteration-count: infinite;
            }
            @keyframes  mycolor{
                0%{
                    left: 0;
                }   
                20%{
                    left: -300px;
                }
                40%{
                    left: -600px;
                }
                60%{
                    left: -900px;
                }
                80%{
                    left: -1200px;
                }
                100%{
                    left: 0;
                }
            }
            .img_container li{
                width: 300px;
                height: 300px;
                float: left;
            }
            .img_container li:nth-child(1){
                background-color: #868686;
            }
            .img_container li:nth-child(2){
                background-color: #FF0000;
            }
            .img_container li:nth-child(3){
                background-color: #228B22;
            }
            .img_container li:nth-child(4){
                background-color: blue;
            }
            .img_container li:nth-child(5){
                background-color: brown;
            }
            .img_container:hover{

            }
            .img_container li a{
                display: block;
                width: 100%;
                height: 100%;
            }
        </style>
    </head>
    <body>
        <div class="container">
            <ul class="img_container">
                <li>
                    <a href="#">
                        <img src="" alt="" />
                    </a>
                </li>
                <li>
                    <a href="#">
                        <img src="" alt="" />
                    </a>
                </li>
                <li>
                    <a href="#">
                        <img src="" alt="" />
                    </a>
                </li>
                <li>
                    <a href="#">
                        <img src="" alt="" />
                    </a>
                </li>
                <li>
                    <a href="#">
                        <img src="" alt="" />
                    </a>
                </li>
            </ul>
        </div>
    </body>
</html>
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值