본문 바로가기

Development/Code

[Code] 이미지 슬라이드 - LightSlider

이미지 슬라이드 - LightSlider



1. HTML 코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>LightSlider Test</title>
    <link rel="stylesheet"  href="https://han3283.cafe24.com/js/lightslider/css/lightslider.css"/>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script src="https://han3283.cafe24.com/js/lightslider/js/lightslider.js"></script>
</head>
 
<body>
    <div class="slide-wrap">
        <div class="slide-content">
            <ul id="slider" class="slider">
                <li class="item1">
                    <h3>사과</h3>
                </li>
                <li class="item2">
                    <h3>체리</h3>
                </li>
                <li class="item3">
                    <h3>딸기</h3>
                </li>
                <li class="item4">
                    <h3>포도</h3>
                </li>
                <li class="item5">
                    <h3>레몬</h3>
                </li>
                <li class="item6">
                    <h3>자몽</h3>
                </li>
            </ul>
        </div>
    </div>
</body>
</html>
cs



2. CSS 코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
ul{
    list-style: none outside none;
    padding-left: 0;
    margin: 0;
}
.slide-content .slide-content{
    margin-bottom: 60px;
}
.slider li{
    text-align: center;
    color: #FFF;
    background-size:cover;
    background-position: center;
}
.slider h3 {
    margin: 0;
    padding: 100px 0;
    height:250px;
}
.slide-content{
    width: 100%;
    height:300px;
}
.item1{background-image:url('http://han3283.cafe24.com/images/apple.jpg');}
.item2{background-image:url('http://han3283.cafe24.com/images/cherry.jpg');}
.item3{background-image:url('http://han3283.cafe24.com/images/strawberry.jpg');}
.item4{background-image:url('http://han3283.cafe24.com/images/grape.jpg');}
.item5{background-image:url('http://han3283.cafe24.com/images/lemon.jpg');}
.item6{background-image:url('http://han3283.cafe24.com/images/grapefruit.jpg');}
cs




3. Script 코드

1
2
3
4
5
6
7
8
9
10
11
$(document).ready(function() {
    $("#slider").lightSlider({
        mode:'slide',    // 이미지가 표시되는 형식 (fade / slide)
        loop:true,       // 무한반복 할 것인지
        auto:true,       // 자동 슬라이드
        keyPress:true,   // 키보드 탐색 허용
        pager:false,     // 페이지 표시
        speed:1500,      // 슬라이드 되는 속도
        pause:3000       // 이미지가 머무는 시간
    });
});
cs




4. LightSlider 옵션 목록


NameExpectedDefaultDescription
itemnumber3number of slides to show at a time
autoWidthbooleanfalseCustom width for each slide
slideMovenumber1Number of slides to be moved at a time
slideMarginnumber10Spacing between each slide
addClassstring''Add custom class for slider, can be used to set different style for different sliders
modestring'slide'Type of transition 'slide' and 'fade'
useCSSbooleantrueIf true LightSlider will use CSS transitions. if falls jquery animation will be used.
cssEasingstring'ease'Type of easing to be used for css animations
easingstring'linear'Type of easing to be used for jquery animations
speednumber400Transition duration (in ms). // ex = speed:400;
autobooleanfalseIf true, the Slider will automatically start to play.
pauseOnHoverbooleanfalsePause autoplay on hover.
loopboleanfalseIf false, will disable the ability to loop back to the beginning of the slide when on the last element.
slideEndAnimationboleantrueEnable slideEnd animation
pausenumber2000The time (in ms) between each auto transition
keyPressbooleanfalseEnable keyboard navigation
controlsbooleantrueIf false, prev/next buttons will not be displayed.
prevHtmlstring''custom html for prev control
nextHtmlstring''custom html for next control
rtlbooleanfalseChange direction to right-to-left
adaptiveHeightbooleanfalseDynamically adjust slider height based on each slide's height
verticalbooleanfalsechange slide's direction from horizontal to Vertical
verticalHeightnumber500set height of slider if vertical mode is active and item more than 1
vThumbWidthnumber100width of gallery thumbnail while vertical mode active
thumbItemnumber10number of gallery thumbnail to show at a time
pagerbooleantrueEnable pager option
gallerybooleantrueEnable thumbnails gallery
galleryMarginnumber5Spacing between gallery and slide
thumbMarginnumber3Spacing between each thumbnails
currentPagerPositionstring'middle'position of thumbnails . 'left', 'middle', 'right'
enableTouchbooleantrueEnables touch support
enableDragbooleantrueEnables desktop mouse drag support
freeMovebooleantrueEnable free move(no limit) while swipe or drag
responsiveobjectnullSeparate settings per breakpoint.


5. Result


See the Pen LightSlider by HanSeungHwa (@hanseunghwa) on CodePen.


'Development > Code' 카테고리의 다른 글

[Code] Record Control Application  (0) 2018.10.30
[Code] Javascript Color Select  (0) 2018.10.30