얼렁뚱땅코드/jquery

0926 마지막 수업_클릭하면 애니메이션 실행하기

얼렁뚱땅 디자이너 2019. 9. 26. 22:29

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <title>Document</title>

    <link rel="stylesheet" href="reset.css">

    <style>

        *{box-sizingborder-box;}

        body{height:100vhbackgroundurl('img/main_bg.jpg'); background-sizecoveroverflowhidden;}

        .section1{width740pxheight:325pxpositionrelative;

                left50%top:50%transformtranslate(-50%,-50%);}

        .section1 img{width100%display:none;}

        .section1 p{positionabsolutebackground#000;}

 

        p.top{width0height1pxleft:0top:0; }

        p.right{width1pxheight0right:0top:0;}

        p.bottom{width0height1pxright:0bottom0;}

        p.left{width1pxheight0left:0bottom:0;}

        

        a.close img{width:50pxpositionabsoluteleft10pxtop:10px;}

 

        h1{positionfixedleft50pxtop50px;}

        .avata{positionabsoluteleft10%top10%;}

        h2{positionabsoluteright10%top:10%;}

        video{positionabsoluteright10%top:24%; }

        .btn{positionabsoluteright10%bottom:10%width640px;}

        .btn li{floatleftwidth50%cursorpointer;}

        .btn li img{width100%;}

    </style>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

    <script>

        $(function(){

            $('.btn1').click(function(){

                alert()

                mainHide()

                sec1show()

            });

 

            $('a.close').click(function(){

                $('.section1 img').fadeOut();

                $('p.top').animate({'width':'0'});

                $('p.right').animate({'height':'0'});

                $('p.bottom').animate({'width':'0'});

                $('p.left').animate({'height':'0'});

            });

 

            function sec1show(){

                $('p.top').animate({'width':'100%'},1000,function(){

                    $('p.right').animate({'height':'100%'},function(){

                        $('p.bottom').animate({'width':'100%'},function(){

                            $('p.left').animate({'height':'100%'},function(){

                                $('.section1 img').fadeIn()

                            })

                        })

                    })

                })

            };

 

            function mainHide(){

                $('.avata').animate({'left':'0'})

                $('video').animate({'top':'0','opacity':'0'})

                $('.btn').animate({'bottom':'0'})

            };

            function mainSow(){

                $('.avata').delay(500).animate({'left':'10%'})

                $('video').delay(500).animate({'top':'10%','opacity':'1'})

                $('.btn').delay(1000).animate({'bottom':'10%','opacity':'1'})

            };

        

        });//function

    </script>

</head>

<body>

    <h1><img src="img/logo.png" alt=""/></h1>

    <div class="avata"><img src="img/main_man.png" alt=""/></div>

    <h2><img src="img/main_txt.png" alt=""/></h2>

    <video src="img/video.mp4"></video>

    <ul class="btn">

        <li class="btn1"><img src="img/btn1.png" alt=""/></li>

        <li class="btn2"></a><img src="img/btn2.png" alt=""/></li>

    </ul>

 

    <section class="section1">

        <p class="top"></p>

        <p class="right"></p>

        <p class="bottom"></p>

        <p class="left"></p>

        <img src="img/section1.png" alt="img"/>

        <a href="#" title="#" class="close">

            <img src="img/iconfinder_basics-22_296812.png" alt=""/>

        </a>

    </section>

</body>

</html>