210411 JavaScript jQuery CSS Position 연습

ITisIT210·2021년 4월 12일
0

jQuery

목록 보기
48/142
post-thumbnail
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 300px;
            height: 300px;
        }

        .box1{background-color: #111;}
        .box2{background-color: #222;}
        .box3{background-color: #333;}
        .box4{background-color: #444;}
        .box5{background-color: #555;}

        .box1{
            position: absolute;
            bottom: 0;
            left: 0;
        }

        .box2{
            position: relative;
            /* top: 20px; */
            /* left: 100px; */
        }

        .box3{
            position: relative;
        }
    </style>
</head>
<body>
    <div class="box1"></div>
    <div class="box2" style="background-color: red"></div>
    <div class="box3"></div>
    <div class="box4"></div>
    <div class="box5"></div>

    <script src="js/jquery-3.6.0.min.js"></script>
    <script>
        $(".box2").on("click", function() {
            $(this).css("left",100);
        })

        $(".box3").on("click", function() {
            $(this).animate({
                "left" : 100
            })
        })

    </script>
</body>
</html>
profile
Engineering is the closest thing to magic that exists in the world.

0개의 댓글