210410 JavaScript jQuery Swatch Scrollpage 풀이 (index.html)

ITisIT210·2021년 4월 12일
0

jQuery

목록 보기
34/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>
    <link rel="stylesheet" href="css/style.css">
    <script src="js/jquery-3.6.0.min.js"></script>
    <script src="js/jquery-ui.min.js"></script>
    <script src="js/jquery.mousewheel.min.js"></script>
    <script src="js/main.js"></script>
</head>
<body>
    <header>
        <h1><a href="#"><img src="images/logo.png" alt=""></a></h1>
        <ul class="gnb">
            <li><a href="#">Full Blossom</a></li>
            <li><a href="#">Be Colorfull</a></li>
            <li><a href="#">Time on Board</a></li>
            <li><a href="#">Shiny Addict</a></li>
        </ul>
    </header>
    <main>
        <section class="s1">
            <div class="txt">
                <h3>FULL BLOSSOM</h3>
                <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>
            </div>
        </section>
        <section class="s2">
            <div class="txt">
                <h3>BE COLORFUL</h3>
                <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>
            </div>
        </section>
        <section class="s3">
            <div class="txt">
                <h3>TIME ON BOARD</h3>
                <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>
            </div>
        </section>
        <section class="s4">
            <div class="txt">
                <h3>SHINY ADDICT</h3>
                <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>
            </div>
        </section>
    </main>

    <!-- <script>
        var i = 0;

        var winHeight = $(window).height();
        //console.log(winHeight);
        $(window).on("scroll", function() {
            var scr = $(this).scrollTop();

            var ofs = $(".gnb li").offset().top;
            console.log(ofs);

            //console.log(scr);

            for (i = 0; i < $("section").length; i++) {
                if (scr >= winHeight * i && scr < winHeight * (i+1)) {
                    $(".gnb li").eq(i).addClass("on").siblings().removeClass("on");
                }
            }

            $(".gnb li").on("click", function() {
                var j = $(this).index();
                $("html, body").stop().animate({
                    "scrollTop" : winHeight * j
                })
            });

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

0개의 댓글