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
๋ณต์ฌ