728x90
<!-- index.html -->
<article id="at1" class="at">
<div class="title title1"></div>
<div class="at1-box">
<ul class="at1-img">
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
<ul class="at1-btn">
<li class="prev"><</li>
<li class="disp">1 / 4</li>
<li class="next">></li>
</ul>
</article>
// index.js
$(function () {
//-- at1 btn img slide
let cnt = 0;
$(".at1-btn li").on("click", function () {
let at1No = $(this).index();
if (at1No == 2 && cnt < 3) {
cnt++;
$(".at1-img").animate({ left: "-=100%" }, 500);
} else if (at1No == 0 && cnt > 0) {
cnt--;
$(".at1-img").animate({ left: "+=100%" }, 500);
}
$(".disp").text(cnt + 1 + " / 4");
});
});
/* index.css */
/* article 1 */
.at1-box {
border: 1px solid black;
width: 500px;
height: 400px;
position: relative;
top: 0;
left: 0;
overflow: hidden;
}
.at1-box .at1-img {
border: 1px solid blue;
width: 2000px;
height: 100%;
display: flex;
position: absolute;
top: 0;
left: 0;
}
.at1-box .at1-img li {
border: 1px solid black;
width: 500px;
height: 100%;
}
.at1-btn {
/* border: 1px solid black; */
width: 500px;
height: 30px;
display: flex;
justify-content: space-between;
}
.at1-btn li {
width: 20%;
height: 100%;
/* border: 1px solid blue; */
text-align: center;
line-height: 30px;
cursor: pointer;
}
결과물
마무리는 overflow: hidden; 으로 영역 밖 이미지 숨김처리
728x90
'IT > Front' 카테고리의 다른 글
[React] Component (0) | 2024.05.14 |
---|---|
[HTML/CSS] Navigation Bar Dropdown (0) | 2024.02.15 |
[CSS] z-index (2) | 2024.02.08 |
[jQuery] .attr() (0) | 2024.02.07 |
[jQuery] 문법 (0) | 2024.02.07 |