Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- SQLD후기
- 팝업레이어
- Slide
- 기초
- 바닐라 자바스크립트
- IP차단
- asp
- 로또 회차
- jQuery
- JSP
- 웹접근성
- 바닐라자바스크립트
- VANILLA
- sqld
- 프론트앤드키워드
- SQL
- git
- CSS
- 코딩공부
- sqld52회차
- 마우스커서
- 애니메이션
- JS
- 웹표준
- 텍스트조절
- github
- 바닐라스크립트
- Python
- TweenMax.js
- 웹개발키워드
Archives
- Today
- Total
단비의 코딩 공부 blog
[jQuery] 플러그인 없이 slide만들기 본문
html
<div class="portBG">
<div class="port">
<div class="slides">
<ul class="slides-container">
<li class="coldaewon">
<div class="view_img"><img src="이미지 URL" alt="이미지1"></div>
<h3>제목<a href="url" target="_blank">View</a></h3>
<ul>
<li>
내용
<li>내용 </li>
<li>사용 색상 :
<span></span>
<span></span>
<span></span>
</li>
</ul>
</li>
<li class="jm">
<div class="view_img"><img src="이미지 URL" alt="이미지2"></div>
<h3>제목 <a href="url" target="_blank">View</a></h3>
<ul>
<li>
내용
<li>내용</li>
<li>사용 색상 :
<span></span>
<span></span>
<span></span>
</li>
</ul>
</li>
<li class="fixfree">
<div class="view_img"><img src="이미지 URL" alt="이미지3"></div>
<h3>제목<a href="url" target="_blank">View</a></h3>
<ul>
<li>내용</li>
<li>내용</li>
<li>사용 색상 :
<span></span>
<span></span>
<span></span>
</li>
</ul>
</li>
</ul>
<div class="prevnext">
<a href="#" class="prev">이전</a>
<a href="#" class="next">다음</a>
</div>
</div>
</div>
</div>
</div>
css
.port{max-width: 1200px; margin: 0 auto; margin-top: 8%; padding: 0 50px;}
.port .slides{position: relative; width:100%; height: 100vh; margin:0 auto; margin-top:40px; opacity: 0; transform: translateY(60px);}
.port .slides.on{transform: translateY(0); opacity:1; transition:all .7s .2s}
.port .slides>.slides-container{width:auto;}
.port .slides>.slides-container>li{display: none; width: calc(100% / 12 * 10); height: auto; text-align: center; position: absolute; top: 0; left: 10%;}
.port .slides>.slides-container>li .view_img{width: 100%;}
.port .slides>.slides-container>li .view_img img{width: 80%;}
.port .slides>.slides-container>li.hospital>ul>li:last-child{text-align: center; padding-left: 20px;}
.port .slides>.slides-container>li>h3{padding-top: 30px;}
.port .slides>.slides-container>li>h3>a{display: inline-block; margin-left:10px; padding:4px 10px; color:#fff; background-color:rgb(252, 97, 255);; font-size: 16px; border-radius: 4px; transition: all 0.3s;}
.port .slides>.slides-container>li>h3>a:hover{transition: all 0.3s; transform: translateY(-6px);}
.port .slides>.slides-container>li>ul{padding-top: 30px; padding-bottom: 30px;}
.port .slides>.slides-container>li>ul>li{margin-bottom:5px; padding-top: 20px;}
.port .slides>.slides-container>li>ul>li>span{display: inline-block; width:10px; height: 10px; margin-left: 5px; border-radius: 50%;}
.view_img img{width: 100%; max-width: 700px;}
.port .slides>.slides-container>li:nth-child(1){display: block;}
.port .slides>.slides-container>li.coldaewon>ul>li>span:nth-child(1){background-color: #c90101;}
.port .slides>.slides-container>li.coldaewon>ul>li>span:nth-child(2){background-color: #013ca2;}
.port .slides>.slides-container>li.coldaewon>ul>li>span:nth-child(3){background-color: #019601;}
.port .slides>.slides-container>li.jm>ul>li>span:nth-child(1){background-color: #ccc;}
.port .slides>.slides-container>li.jm>ul>li>span:nth-child(2){background-color: #fff;}
.port .slides>.slides-container>li.jm>ul>li>span:nth-child(3){background-color: #000;}
.port .slides>.slides-container>li.fixfree>ul>li>span:nth-child(1){background-color: #ddd;}
.port .slides>.slides-container>li.fixfree>ul>li>span:nth-child(2){background-color: #fff;}
.port .slides>.slides-container>li.fixfree>ul>li>span:nth-child(3){background-color: pink;}
.prevnext{position: absolute; top:28%; width:100%}
.prev, .next{position: absolute; display: block; width:30px; height: 30px; text-indent: -9999px; background-size: cover; opacity: 0.7;transition: all 0.3s;}
.prev{left:0%; background-image: url(../img/left-arrow.png);}
.next{right:0%; background-image: url(../img/right-arrow.png);}
jQuery
var $paging = $(".slides_container>li>a");
var pagingIdx = 0;
$(".prev").click(function (evt) {
evt.preventDefault();
if (pagingIdx >= 0) {
pagingIdx--;
$(".slides-container>li").eq(pagingIdx).fadeIn().siblings().fadeOut();
}else{
pagingIdx = 1;
$(".slides-container>li").eq(pagingIdx).fadeIn().siblings().fadeOut();
}
$paging.eq(pagingIdx).parent().addClass("on").siblings().removeClass("on");
});
$(".next").click(function (evt) {
evt.preventDefault();
if (pagingIdx <= 1) {
pagingIdx++;
$(".slides-container>li").eq(pagingIdx).fadeIn().siblings().fadeOut();
} else {
pagingIdx = 0;
$(".slides-container>li").eq(pagingIdx).fadeIn().siblings().fadeOut();
}
$paging.eq(pagingIdx).parent().addClass("on").siblings().removeClass("on");
});
* 만들려고 하는 슬라이드의 갯수만큼 pagingIdx 를 수정해 주어야함
'javascript&jquery' 카테고리의 다른 글
[Vanilla JS]study 1일차 - 기본문법과 변수 (0) | 2022.11.22 |
---|---|
[javascript]플러그인 없이 슬롯 머신 만들기 (0) | 2022.10.20 |
[jQuery] css 변경하기 (추가, 수정, 삭제) (0) | 2022.10.12 |
[javascript] 플러그인 없이 blick 팝업 만들기 (0) | 2022.10.05 |
[javascript] IP 차단하기 (0) | 2022.09.29 |