221117 pash_hash.html (사계절)

2022. 11. 17. 11:26·Skills/JavaScript
<!DOCTYPE html>
<html lang="ko">
  <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>full_page_indicator</title>
    <script src="https://code.jquery.com/jquery-3.6.1.min.js"></script>
    <script src="./js/jquery.scrollTo.min.js"></script>
    <script>
      $(function () {
        const btn = $(".lnb li");
        const section = $(".contents section");

        $(".lnb").css("top", $(window).height() / 2 - $(".lnb").height() / 2);

        $(window).scroll(function () {
          let point =
            $(this).scrollTop() +
            $(window).height() / 2 -
            $(".lnb").height() / 2;
          $(".lnb").stop().animate({ top: point }, 500);

          section.each(function () {
            let sectionPoint = $(window).scrollTop();
            let target = $(this);
            let i = target.index();

            if (sectionPoint >= target.offset().top) {
              btn.removeClass("on");
              btn.eq(i).addClass("on");
            }
          });
        });

        btn.click(function () {
          let target = $(this);
          let i = target.index();

          let targetSection = section.eq(i);
          let point = targetSection.offset().top;

          $("html, body").stop().animate({ scrollTop: point }, 1000);
        });
      });
    </script>

    <style>
      * {
        margin: 0;
        padding: 0;
      }

      li {
        list-style: none;
      }

      .lnb {
        position: absolute;
        right: 20px;
      }

      .lnb li {
        background-color: #333;
        width: 25px;
        height: 25px;
        border-radius: 25px;
        margin-bottom: 10px;
      }

      .lnb li:last-child {
        margin-bottom: 0;
      }

      .lnb li a {
        display: block;
        font-size: 16px;
        color: white;
        text-decoration: none;
        text-align: center;
        line-height: 25px;
      }

      .lnb li.on a {
        color: crimson;
      }

      .contents section {
        height: 100vh;
        font-size: 100px;
        display: flex;
        justify-content: center;
      }

      .contents section img {
        height: 100vh;
      }
      
      #page01 {
        background-color: palevioletred;
      }
      #page02 {
        background-color: teal;
      }
      #page03 {
        background-color: orangered;
      }
      #page04 {
        background-color: dimgray;
      }
    </style>
  </head>
  <body>
    <nav class="lnb">
      <ul>
        <li class="on"><a href="#page01">春</a></li>
        <li><a href="#page02">夏</a></li>
        <li><a href="#page03">秋</a></li>
        <li><a href="#page04">冬</a></li>
      </ul>
    </nav>

    <div class="contents">
      <section id="page01"><img src="./images/spring.jpg" alt="" /></section>
      <section id="page02"><img src="./images/summer.jpg" alt="" /></section>
      <section id="page03"><img src="./images/fall.jpg" alt="" /></section>
      <section id="page04"><img src="./images/winter.jpg" alt="" /></section>
    </div>
  </body>
</html>

images.zip
7.78MB

'Skills > JavaScript' 카테고리의 다른 글

221121 full_pageanimate.html  (0) 2022.11.21
221121 full_pagescroll.html  (0) 2022.11.21
221117 quick_menu.html  (0) 2022.11.17
221117 tab_sheet.html  (0) 2022.11.17
221116 page_hash.html  (1) 2022.11.16
'Skills/JavaScript' 카테고리의 다른 글
  • 221121 full_pageanimate.html
  • 221121 full_pagescroll.html
  • 221117 quick_menu.html
  • 221117 tab_sheet.html
개발자 윤구나
개발자 윤구나
개발 공부를 하고 있습니다. Let's go!
  • 개발자 윤구나
    이것은 무엇?????
    개발자 윤구나
    • 분류 전체보기
      • Skills
        • Java
        • Database
        • Flutter, Dart
        • JavaScript
        • React
        • HTML5
        • CSS3, SCSS
        • PHP
        • C#
        • Unity
        • Algorithm
        • GIT·GitHub
        • 그 외
      • Book Review
      • IT NEWS
      • 설계
      • 자기 계발
  • 블로그 메뉴

    • 홈
    • 방명록
  • 인기 글

  • 최근 글

  • 최근 댓글

  • 전체
    오늘
    어제
  • hELLO· Designed By정상우.v4.10.3
개발자 윤구나
221117 pash_hash.html (사계절)
상단으로

티스토리툴바