星を達成するためのHTML + JS + CSS

<!DOCTYPE HTML > 
< HTML LANG = "EN" > 
< > 
    < メタ文字コード= "UTF-8" > 
    < タイトル>满天星</ タイトル> 
    < スタイル> 
        * { 
            マージン0 ; 
            パディング0 ; 
        }

        HTML、本体{ 100% 
            高さ100%; 
            背景色
            位置相対; 
        } 
        .starアニメーション{ 
            位置相対
            トップ0 ; 0 ; 100%; 
            高さ100%; 
            オーバーフロー隠されました; 
        }

        / * アニメーション* / 
        @ -webkit識別子キーフレーム{
            25%{
                変換スケール(1.5); 
            } 
            50%{ 
                変換スケール(2) 
            } 
            75%{ 
                変換スケール(1.5) 
            } 
            100%{ 
                変換スケール(1) 
            }

        }

        @ -O-キーフレーム識別子{
            25%{
                変換スケール(1.5); 
            } 
            50%{ 
                変換スケール(2) 
            } 
            75%{ 
                変換スケール(1.5) 
            } 
            100%{ 
                変換スケール(1) 
            }

        }

        @ -moz-キーフレーム識別子{
            25%{
                変換スケール(1.5); 
            } 
            50%{ 
                変換スケール(2) 
            } 
            75%{ 
                変換スケール(1.5) 
            } 
            100%{ 
                変換スケール(1) 
            }

        }

        @keyframes識別子{
            25%{
                変換スケール(1.5); 
            } 
            50%{ 
                変換スケール(2) 
            } 
            75%{ 
                変換スケール(1.5) 
            } 
            100%{ 
                変換スケール(1) 
            }

        }
    300 ; I ++







    
  ){
            container.append(starFactory())。
        }
    })(document.getElementsByClassName(" スター・アニメーション" )[ 0 ])。

    // ファクトリ関数の星を作成する
    関数{)(starFactoryを
        聞かせてスター= のdocument.createElement(" DIV " );
        聞かせて幅= Math.ceil(Math.random()* 5 )。
        star.style.position =  絶対
        star.style.width = +  ピクセル
        star.style.height = +  ピクセル
        star.style.backgroundColor =  ' #909090 ' ;
        star.style.top = Math.ceil(Math.random()* window.innerHeight)+  ' PX ' 
        star.style.left = Math.ceil(Math.random()* window.innerWidth)+  ' PX ' 
        star.style.boxShadow =  " #545454 0 " + Math.ceil(Math.random()* 5 + " PX " + Math.ceil(Math.random()* 5 + " 5pxの" 
        star.style.borderRadius = +  ピクセル

        // 直径未満三つ星、ズームアニメーションである場合
        IF (幅<  3 ){
            star.style.animation =  識別子2000ミリ秒無限の500ミリ秒を
        }
        リターン・スター;
    }

</ スクリプト> 
</ HTML >
コードの表示

効果:

 

おすすめ

転載: www.cnblogs.com/hello-dummy/p/11361210.html