슬라이드 적용하기
포스트
취소

슬라이드 적용하기

사용 방법

<!-- Link Swiper's CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css" />
<style>
    .swiper-container {
        width: 100%;
        height: 100%;
        padding: 50px;
    }

    .swiper-slide {
        background-position: center;
        background-size: cover;
        width: 300px;
        height: 300px;
    }

    .swiper-slide img {
        display: block;
        width: 100%;
        height: 100%;
    }
</style>

<div class="swiper">
  <div class="swiper-wrapper">
    <!-- 반복 시작 -->
    <div class="swiper-slide">
        <img src="."/>
    </div>
    <!-- 반복 종료 -->
  </div>

  <div class="swiper-pagination"></div>

  <div class="swiper-button-prev"></div>
  <div class="swiper-button-next"></div>
</div>

<!-- Swiper JS -->
<script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>
<script>
    const swiper = new Swiper(".swiper", {
        slidesPerView: 1,
        grabCursor: true,
        loop: true,
        pagination: {
            el: ".swiper-pagination",
            clickable: true,
        },
        navigation: {
            nextEl: ".swiper-button-next",
            prevEl: ".swiper-button-prev",
        },
    });
</script>
이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.