Search

fx-slider

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

<link rel="stylesheet" href="https://cdn.jsdelivr.net/bxslider/4.2.12/jquery.bxslider.css"> <link rel="stylesheet" href="css/style.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script src="https://cdn.jsdelivr.net/bxslider/4.2.12/jquery.bxslider.min.js"></script> <script src="js/script.js"></script>
HTML
๋ณต์‚ฌ

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

<div class="wrap"> <div class="slide-container"> <div class="slide"><img src="img/slide01.jpg" alt="" title="์ด๋ฏธ์ง€01"></div> <div class="slide"><img src="img/slide02.jpg" alt="" title="์ด๋ฏธ์ง€02"></div> <div class="slide"><img src="img/slide03.jpg" alt="" title="์ด๋ฏธ์ง€03"></div> <div class="slide"><img src="img/slide04.jpg" alt="" title="์ด๋ฏธ์ง€04"></div> <div class="slide"><img src="img/slide05.jpg" alt="" title="์ด๋ฏธ์ง€05"></div> <div class="slide"><img src="img/slide06.jpg" alt="" title="์ด๋ฏธ์ง€06"></div> </div> </div>
HTML
๋ณต์‚ฌ

3. ๊ธฐ๋ณธ ์Šคํƒ€์ผ ์ ์šฉํ•˜๊ธฐ

.wrap { width: 1200px; height: 480px; margin: 200px auto; } /* ์Šฌ๋ผ์ด๋“œ */ .slide { width: auto; height: 480px; } /* ์Šฌ๋ผ์ด๋“œ ์ด๋ฏธ์ง€ */ .slide img { width: 100%; height: 100%; } /* ๊ธฐ๋ณธ ์ปค์Šคํ…€ */ .bx-wrapper { -moz-box-shadow: 0 0 0 transparent; -webkit-box-shadow: 0 0 0 transparent; box-shadow: 0 0 0 transparent; border: 0px solid #fff; background: #fff; }
HTML
๋ณต์‚ฌ

ํŽ˜์ด์ง€๋„ค์ด์…˜ ์ปค์Šคํ…€

/************** ํŽ˜์ด์ง€๋„ค์ด์…˜ ์ปค์Šคํ…€ **************/ .bx-wrapper .bx-pager, .bx-wrapper .bx-controls-auto { bottom: 20px; /* ํŽ˜์ด์ง€ ๋„ค์ด์…˜ ์Šฌ๋ผ์ด๋“œ ์•ˆ์œผ๋กœ */ } /* ํŽ˜์ด์ง€๋„ค์ด์…˜ ์ปค์Šคํ…€ - ๋‹ท์ธ  */ .bx-wrapper .bx-pager.bx-default-pager a { background-color: #fff; } /* ํŽ˜์ด์ง€๋„ค์ด์…˜ ์ปค์Šคํ…€ - ํ™œ์„ฑํ™”๋œ ๋‹ท์ธ  */ .bx-wrapper .bx-pager.bx-default-pager a:hover, .bx-wrapper .bx-pager.bx-default-pager a.active, .bx-wrapper .bx-pager.bx-default-pager a:focus { background-color: pink; } .bx-wrapper .bx-pager.bx-default-pager a { border-radius: 0; width: 20px; height: 5px; }
CSS
๋ณต์‚ฌ

ํ™”์‚ดํ‘œ ์ปค์Šคํ…€

/************** ๋„ค๋น„๊ฒŒ์ด์…˜ ํ™”์‚ดํ‘œ ์ปค์Šคํ…€ **************/ .bx-wrapper .bx-prev { background: url(../img/prev.png) no-repeat left center; background-size: 32px 32px;} .bx-wrapper .bx-next { background: url(../img/next.png) no-repeat left center; background-size: 32px 32px;} .bx-wrapper .bx-prev:hover, .bx-wrapper .bx-prev:focus { background-position: 0 0; } .bx-wrapper .bx-prev:hover { filter: brightness(60%); } .bx-wrapper .bx-next:hover, .bx-wrapper .bx-next:focus { background-position: 0 0; } .bx-wrapper .bx-next:hover { filter: brightness(60%); }
CSS
๋ณต์‚ฌ

4. script ์ฝ”๋“œ ์ ์šฉํ•˜๊ธฐ

$(function(){ // bx-slider ์‹œ์ž‘! $('.slide-container').bxSlider({ mode: 'horizontal', // ํŽ˜์ด๋“œ ํšจ๊ณผ๋กœ ์Šฌ๋ผ์ด๋“œ : 'horizontal', 'vertical', 'fade' captions: true, // ์ด๋ฏธ์ง€ ํ•˜๋‹จ์˜ ์ œ๋ชฉ slideWidth: 1200, // ์Šฌ๋ผ์ด๋“œ ๊ฐ€๋กœ ํฌ๊ธฐ ์ง€์ • auto: true, // ์ž๋™์žฌ์ƒ pause: 2000, // ์Šฌ๋ผ์ด๋“œ ๋‹น ์žฌ์ƒ ์‹œ๊ฐ„ (ms) autoControls: true, // ์žฌ์ƒ๋ฒ„ํŠผ, ์ค‘์ง€๋ฒ„ํŠผ stopAutoOnClick: true, // ํด๋ฆญํ•  ๋•Œ, ์ž๋™์žฌ์ƒ ๋ฉˆ์ถค pager: true, // ํŽ˜์ด์ง€๋„ค์ด์…˜ speed: 500, // ์Šฌ๋ผ์ด๋“œ๊ฐ€ ์ „ํ™˜๋˜๋Š” ์‹œ๊ฐ„ (ms) keyboardEnabled: true, // ํ‚ค๋ณด๋“œ ์‚ฌ์šฉ๊ฐ€๋Šฅ ์—ฌ๋ถ€ moveSlides: 1, // ์ „ํ™˜๋  ์Šฌ๋ผ์ด๋“œ ๊ฐœ์ˆ˜ minSlides: 3, // ์ตœ์†Œ ์Šฌ๋ผ์ด๋“œ ๊ฐœ์ˆ˜ maxSlides: 4, // ์ตœ๋Œ€ ์Šฌ๋ผ์ด๋“œ ๊ฐœ์ˆ˜ }); });
JavaScript
๋ณต์‚ฌ