이미지 슬라이드 - 위로 움직이기
<main>
<div class="slider-wrap">
<div class="slider-img slider-img1">
<div class="slider-inner slider-inner1">
<div class="slider slider1" data-name="이미지1">
<img src="../assets/img/bg26.jpg" alt="이미지1">
</div>
<div class="slider slider1" data-name="이미지2">
<img src="../assets/img/bg27.jpg" alt="이미지2">
</div>
<div class="slider slider1" data-name="이미지3">
<img src="../assets/img/bg28.jpg" alt="이미지3">
</div>
<div class="slider slider1" data-name="이미지4">
<img src="../assets/img/bg29.jpg" alt="이미지4">
</div>
<div class="slider slider1" data-name="이미지5">
<img src="../assets/img/bg21.jpg" alt="이미지5">
</div>
</div>
</div>
<div class="slider-img slider-img2">
<div class="slider-inner slider-inner2">
<div class="slider slider2" data-name="이미지1">
<img src="../assets/img/bg26.jpg" alt="이미지1">
</div>
<div class="slider slider2" data-name="이미지2">
<img src="../assets/img/bg27.jpg" alt="이미지2">
</div>
<div class="slider slider2" data-name="이미지3">
<img src="../assets/img/bg28.jpg" alt="이미지3">
</div>
<div class="slider slider2" data-name="이미지4">
<img src="../assets/img/bg29.jpg" alt="이미지4">
</div>
<div class="slider slider2" data-name="이미지5">
<img src="../assets/img/bg21.jpg" alt="이미지5">
</div>
</div>
</div>
</div>
</main>
/* slider */
.slider-wrap {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.slider-img {
width: 600px;
height: 360px;
overflow: hidden;
margin: 10px;
}
.slider-img img {
width: 100%;
}
.slider-inner {
position: relative;
width: 600px;
height: 1800px;
overflow: hidden;
}
.slider-inner .slider {
float: left;
width: 600px;
height: 360px;
position: relative;
}
.slider-inner .slider::before {
position: absolute;
left: 5px;
top: 5px;
background: rgba(0,0,0,.4);
color: #fff;
padding: 5px 10px 3px;
font-family: 'NEXONLv1Gothic';
}
.slider-inner .slider:nth-child(1) {
z-index: 5;
}
.slider-inner .slider:nth-child(2) {
z-index: 4;
}
.slider-inner .slider:nth-child(3) {
z-index: 3;
}
.slider-inner .slider:nth-child(4) {
z-index: 2;
}
.slider-inner .slider:nth-child(5) {
z-index: 1;
}
.slider-inner .slider::before {
content: attr(data-name);
}
// slider1
const sliderImg1 = $(".slider-img1");
const sliderInner1 = $(".slider-inner1");
const slider1 = $(".slider1");
let currentIndex1 = 0;
let sliderHeight1 = slider1.height();
setInterval(function(){
currentIndex1 < 4 ? currentIndex1++ : currentIndex1 = 0;
let sliderPosition = currentIndex1 * -sliderHeight1;
sliderInner1.animate({top: sliderPosition}, 600, "easeOutExpo");
}, 3000);
// slider2
const sliderImg2 = $(".slider-img2");
const sliderInner2 = $(".slider-inner2");
const slider2 = $(".slider2");
let currentIndex2 = 0;
let sliderHeight2 = slider2.height();
setInterval(function(){
sliderInner2.animate({top: -sliderHeight2}, 600, "easeOutExpo", function(){
$(".slider2:first-child").appendTo(sliderInner2);
sliderInner2.css("top", "");
});
}, 3000);
// 소스보기 실행함수
modal();