Acticle 15:css3动画小例子(幻灯片播放)

幻灯片播放的代码:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title></title>
        <style type="text/css">
        /*<!--兼容性不大好-->*/
            *{
                padding: 0;
                margin: 0;
                list-style: none;
            }
            ul{
                width:100%;
                height:100%;
                position: fixed;
            }
            ul li{
                width: 100%;
                height: 100%;
                position: absolute;
                top: 0;
                left: 0;
                opacity: 0; 
                animation:cartoon 10s linear infinite;/*animation为动画属性:有四个参数,1.代表动画的名称,2.动画完成的时长 3.动画的运动方式 4.运动的次数*
                /*1.ease-in-out显示的速度先快后慢   2.linear 匀速  3.ease速度由快到慢,逐渐变慢  4.ease-out速度越来越慢 5.ease-in速度越来越快*/
                }
            img{
                    width:100%;
                    height: 100%;
                }
                ul li:nth-of-type(1){
                    animation-delay: 0s;/*animation-delay动画等待开始的时间*/
                    -moz-animation-delay: 0s;
                }
                ul li:nth-of-type(2){
                    animation-delay: 2s;
                    -moz-animation-delay: 2s;
                }
                ul li:nth-of-type(3){
                    animation-delay: 4s;
                    -moz-animation-delay: 4s;
                }
                ul li:nth-of-type(4){
                    animation-delay: 6s;
                    -moz-animation-delay: 6s;
                }
                ul li:nth-of-type(5){
                    animation-delay: 8s;
                    -moz-animation-delay: 8s;
                }
                ul li:nth-of-type(6){
                    animation-delay: 10s;
                    -moz-animation-delay: 10s;
                }
            @keyframes cartoon{     /*a.@keyframes:@keyframes 规则用于创建动画,即为想让动画动起来,需要绑定@keyframe规则   
                b.@keyframes规则:一般用百分比来规定变化发生的时间,或用关键词 "from" 和 "to",等同于 0% 和 100%。
                c.0% 是动画的开始,100% 是动画的完成。*/
                0%{opacity: 0;}    /*每张图片都经历这样一个透明度由0到1,再由1到0的过程,即:图片慢慢的出现,之后又慢慢的消失。*/
                20%{opacity: 1;}
                40%{opacity: 1;}
                60%{opacity: 1;}
                80%{opacity: 1;}
                100%{opacity: 0;}
            }
        </style>
    </head>
    <body>
        <ul>
            <li><img src="img/1.jpeg"/></li>
            <li><img src="img/2.jpg"/></li>
            <li><img src="img/3.jpg"/></li>
            <li><img src="img/4.jpg"/></li>
            <li><img src="img/5.jpg"/></li>
            <li><img src="img/6.jpeg"/></li>
        </ul>
    </body>
</html>

运行结果:
这里写图片描述
在老师的代码进行了稍稍改动。
运行效果是:通过改变图片的透明度,实现动画幻灯片播放的效果。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值