亚洲免费乱码视频,日韩 欧美 国产 动漫 一区,97在线观看免费视频播国产,中文字幕亚洲图片

      1. <legend id="ppnor"></legend>

      2. 
        
        <sup id="ppnor"><input id="ppnor"></input></sup>
        <s id="ppnor"></s>

        css3中利用animation屬性創(chuàng)建雪花飄落特效

        字號:


            先介紹一下css3中的animation的特性吧。
            在css3中我們可以使用animation屬性來創(chuàng)建復(fù)雜的動畫效果,包括移動,旋轉(zhuǎn),縮放,傾斜(后幾個請參考css3中的transform,scale等屬性)等。而這一切,只需要我們創(chuàng)建關(guān)鍵幀(@keyframes),然后將自己想要實現(xiàn)的動作添加進去就可以實現(xiàn)。
            比如:
            代碼如下:
            @keyframes bgchange{
            from {background:red;}
            to {background:yellow}
            }
            div:hover{
            animation:bgchange 5s;
            }
            當(dāng)鼠標懸停在<div>時,該<div>的背景顏色會在五秒之內(nèi)從紅色變?yōu)辄S色。
            注意:使用animation和@keyframes時不同瀏覽器需要加上不同的前綴名!
            下面代碼實現(xiàn)雪花飄落功能:
            代碼如下:
            <!doctype html>
            <html>
            <head>
            <meta charset=utf-8 />
            <title>snowing snow</title>
            <style>
            body{
            background: #eee;
            }
            @keyframes mysnow{
            0%{
            bottom:100%;
            opacity:0;
            }
            50%{
            opacity:1;
            transform: rotate(1080deg);
            }
            100%{
            transform: rotate(0deg);
            opacity: 0;
            bottom:0;
            }
            }
            @-webkit-keyframes mysnow{
            0%{
            bottom:100%;
            opacity:0;
            }
            50%{
            opacity:1;
            -webkit-transform: rotate(1080deg);
            }
            100%{
            -webkit-transform: rotate(0deg);
            opacity: 0;
            bottom:0;
            }
            }
            @-moz-keyframes mysnow{
            0%{
            bottom:100%;
            opacity:0;
            }
            50%{
            opacity:1;
            -moz-transform: rotate(1080deg);
            }
            100%{
            -moz-transform: rotate(0deg);
            opacity: 0;
            bottom:0;
            }
            }
            @-ms-keyframes mysnow{
            0%{
            bottom:100%;
            opacity:0;
            }
            50%{
            opacity:1;
            -ms-transform: rotate(1080deg);
            }
            100%{
            -ms-transform: rotate(0deg);
            opacity: 0;
            bottom:0;
            }
            }
            @-o-keyframes mysnow{
            0%{
            bottom:100%;
            opacity:0;
            }
            50%{
            opacity:1;
            -o-transform: rotate(1080deg);
            }
            100%{
            -o-transform: rotate(0deg);
            opacity: 0;
            bottom:0;
            }
            }
            .roll{
            position:absolute;
            opacity:0;
            animation: mysnow 5s ;
            -webkit-animation: mysnow 5s ;
            -moz-animation: mysnow 5s ;
            -ms-animation: mysnow 5s ;
            -o-animation: mysnow 5s ;
            height:80px;
            }
            .div{
            position:fixed;
            }
            </style>
            </head>
            <body>
            <div id=snowzone >
            </div>
            </body>
            <script>
            (function(){
            function snow(left,height,src){
            var div = document.createelement(div);
            var img = document.createelement(img);
            div.appendchild(img);
            img.classname = roll;
            img.src = src;
            div.style.left=left+px;
            div.style.height=height+px;
            div.classname=div;
            document.getelementbyid(snowzone).appendchild(div);
            settimeout(function(){
            document.getelementbyid(snowzone).removechild(div);
            // console.log(window.innerheight);
            },5000);
            }
            setinterval(function(){
            var left = math.random()*window.innerwidth;
            var height = math.random()*window.innerheight;
            var src = s+math.floor(math.random()*2+1)+.png;//兩張圖片分別為s1.png、s2.png
            snow(left,height,src);
            },500);
            })();
            </script>
            </html>