Search

swiper

swiper ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ

1. swiper ํ”Œ๋Ÿฌ๊ทธ์ธ ๊ฐ€์ ธ์˜ค๊ธฐ

index.html

<!-- swiper ํ”Œ๋Ÿฌ๊ทธ์ธ --> <link rel="stylesheet" href="https://unpkg.com/swiper@7/swiper-bundle.min.css"/> <link rel="stylesheet" href="css/style.css"> <!-- jQuery --> <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> <!-- swiper ํ”Œ๋Ÿฌ๊ทธ์ธ --> <script src="https://unpkg.com/swiper@7/swiper-bundle.min.js"></script> <script src="js/script.js"></script>
HTML
๋ณต์‚ฌ

2. swiper HTML ๋ ˆ์ด์•„์›ƒ ์ฝ”๋“œ

index.html

<!-- Slider main container --> <div class="swiper"> <!-- Additional required wrapper --> <div class="swiper-wrapper"> <!-- Slides --> <div class="swiper-slide">Slide 1</div> <div class="swiper-slide">Slide 2</div> <div class="swiper-slide">Slide 3</div> ... </div> <!-- If we need pagination --> <div class="swiper-pagination"></div> <!-- If we need navigation buttons --> <div class="swiper-button-prev"></div> <div class="swiper-button-next"></div> <!-- If we need scrollbar --> <div class="swiper-scrollbar"></div> </div>
HTML
๋ณต์‚ฌ

3. ๊ธฐ๋ณธ ์Šคํƒ€์ผ ์ง€์ •

style.css

.swiper { width: 600px; height: 300px; }
CSS
๋ณต์‚ฌ

4. swiper ์‹œ์ž‘ํ•˜๊ธฐ

script.js

$(function () { // ์Šค์™€์ดํผ ์‹œ์ž‘! const swiper = new Swiper('.swiper', { // Optional parameters direction: 'vertical', loop: true, // If we need pagination pagination: { el: '.swiper-pagination', }, // Navigation arrows navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, // And if we need scrollbar scrollbar: { el: '.swiper-scrollbar', }, }); })
JavaScript
๋ณต์‚ฌ

5. ์ด๋ฏธ์ง€ ์ ์šฉํ•˜๊ธฐ

<!-- Slider main container --> <div class="swiper"> <!-- Additional required wrapper --> <div class="swiper-wrapper"> <!-- Slides --> <!-- (.swiper-slide>img[src="../img/slide$$.jpg"])*10 --> <div class="swiper-slide"><img src="img/slide01.jpg" alt=""></div> <div class="swiper-slide"><img src="img/slide02.jpg" alt=""></div> <div class="swiper-slide"><img src="img/slide03.jpg" alt=""></div> <div class="swiper-slide"><img src="img/slide04.jpg" alt=""></div> <div class="swiper-slide"><img src="img/slide05.jpg" alt=""></div> <div class="swiper-slide"><img src="img/slide06.jpg" alt=""></div> <div class="swiper-slide"><img src="img/slide07.jpg" alt=""></div> <div class="swiper-slide"><img src="img/slide08.jpg" alt=""></div> <div class="swiper-slide"><img src="img/slide09.jpg" alt=""></div> <div class="swiper-slide"><img src="img/slide10.jpg" alt=""></div> </div> <!-- If we need pagination --> <div class="swiper-pagination"></div> <!-- If we need navigation buttons --> <div class="swiper-button-prev"></div> <div class="swiper-button-next"></div> <!-- If we need scrollbar --> <div class="swiper-scrollbar"></div> </div>
HTML
๋ณต์‚ฌ

6. ๋‹ค์–‘ํ•œ ์˜ต์…˜

$(function() { const swiper = new Swiper('.swiper', { // Optional parameters direction: 'horizontal', /* ์Šฌ๋ผ์ด๋“œ ๋ฐฉํ–ฅ : 'vertical' , 'horizontal' */ loop: true, // ๋ฐ˜๋ณต์—ฌ๋ถ€ autoplay: { // ์ž๋™์žฌ์ƒ delay: 3000, // ์Šฌ๋ผ์ด๋“œ ๋‹น ์ง€์—ฐ์‹œ๊ฐ„ (ms) pauseOnMouseEnter: false, // ๋งˆ์šฐ์Šค ์˜ฌ๋ฆฌ๋ฉด, ์ž๋™์žฌ์ƒ ๋ฉˆ์ถค disableOnInteraction: false, // ์ธํ„ฐ๋ ‰์…˜(ํ™”์‚ดํ‘œ,๋“œ๋ž˜๊ทธ,...) ์ค‘ ์ž๋™์žฌ์ƒ ๋น„ํ™œ์„ฑํ™” }, speed: 2000, // ์Šฌ๋ผ์ด๋“œ๊ฐ€ ๋„˜์–ด๊ฐ€๋Š” ์‹œ๊ฐ„ (ms) slidesPerView: 1, // ๋ณด์—ฌ์ง€๋Š” ์Šฌ๋ผ์ด๋“œ ๊ฐœ์ˆ˜ spaceBetween: 0, // ์Šฌ๋ผ์ด๋“œ ๊ฐ„ ์—ฌ๋ฐฑ grabCursor: true, // ๋งˆ์šฐ์Šค์ปค์„œ๋ฅผ ์žก๋Š” ์†๊ฐ€๋ฝ ๋ชจ์–‘ centeredSlides: true, // ์„ผํ„ฐ๋ชจ๋“œ /* ๋‹ค์–‘ํ•œ ํšจ๊ณผ */ // fade /* effect: "fade", fadeEffect: { crossFade: true }, */ // coverflow /* effect: "coverflow", coverflowEffect: { rotate: 20, slideShadows: true, scale: 1, }, */ // cube /* effect: 'cube', cubeEffect: { shadow: false, slideShadow: false, }, */ // cards effect: 'cards', cardsEffect: { rotate: false, }, // If we need pagination pagination: { el: '.swiper-pagination', type: 'bullets', // 'bullets' : โ— โ— โ— // 'fraction' : (ํ˜„์žฌ๋ฒˆํ˜ธ/์ „์ฒด๋ฒˆํ˜ธ) // 'progressbar' : ์ง„ํ–‰๋ฅ (๊ฒŒ์ด์ง€) clickable: true, }, // Navigation arrows navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, // And if we need scrollbar scrollbar: { el: '.swiper-scrollbar', // ์Šคํฌ๋กค๋ฐ”๊ฐ€ ์ ์šฉ๋  ์š”์†Œ hide: true, // ์Šคํฌ๋กค๋ฐ” ์ˆจ๊น€(์ง์ ‘ ์›€์ง์ผ ๋•Œ๋Š” ๋ณด์ด๊ณ , ๊ทธ์™ธ์— ์ˆจ๊น€) draggable: true, // ์Šคํฌ๋กค๋ฐ” ๋“œ๋ž˜๊ทธ ๊ฐ€๋Šฅ ์—ฌ๋ถ€ snapOnRelease: true, // ์Šคํฌ๋กค๋ฐ” ๋†“์„ ๋•Œ, ์Šฌ๋ผ์ด๋“œ ์œ„์น˜ ๋งž์ถค }, }); })
JavaScript
๋ณต์‚ฌ