묻고답하기
슬라이더 질문입니다.
2017.06.28 14:51
본문소스를 올립니다.
슬라이더3에서 1로 돌아갈때 pre/next 함수를 만들어 자연스럽게 보이게 하고 싶은데 잘 안되네요
고수님들 도움주시면 감사하겠습니다.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<style>
* {margin:0;padding:0;}
#wrap {
width:100%;
height:600px;
position: relative;
}
.wrap_abs_slider {
width:100%;
position: absolute;
left:0;
top:100px;
height:500px;
z-index: 0;
}
.wrap_sl_rel {
width:100%;
height:100%;
position: relative;
overflow: hidden;
}
.wrap_sl_rel>img {
position: absolute;
top:0;
width:100%;
height:500px;
}
.sl_img01 {
left:0%;
z-index: 3;
}
.sl_img02 {
left:100%;
z-index: 2;
}
.sl_img03 {
left:200%;
z-index: 1;
}
.wrap_abs_con {
position:absolute;
width:1000px;
left:50%;
margin-left:-500px;
top:100px;
z-index: 1;
height:500px;
}
.wrap_con_rel {
position: relative;
width:100%;
height:100%;
}
.wrap_con_rel>button {
position: absolute;
top:50%;
margin-top:-15px;
height:30px;
width:100px;
border:0;
background-color:#ff0000;
color:#fff;
}
.left {
left:0;
}
.right{
right:0;
}
.s_btn {
position: absolute;
left:50%;
margin-left: -75px;
width:150px;
height:30px;
list-style-type: none;
bottom:10px;
overflow: hidden;
}
.s_btn>li {
float: left;
}
.s_btn>li>a {
display: block;
width:30px;
height:30px;
margin-right:20px;
background-color: gray;
border-radius:15px;
}
.s_btn>li:nth-child(3)>a {
margin-right: 0;
}
.s_btn>li>a:hover {
background-color: #f00;
}
</style>
</head>
<body>
<script type="text/javascript">
$(function(){
var w01 = 0;
var w02 = 0;
var w03 = 0;
sl01 ();
setInterval(right_Click,3000);
$('.right').click(function(){
if(w01 == 1){
sl02();
}
else if(w02 == 1) {
sl03();
}
else if(w03 == 1){
sl_Next();
}
});
$('.left').click(function(){
if(w01 == 1){
sl_Pre();
}
else if(w02 == 1) {
sl01();
}
else if(w03 == 1){
sl02();
}
});
function right_Click() {
$('.right').trigger('click');
}
function sl_Pre() {
w01 = 0;
w02 = 0;
w03 = 1;
$('.sl_img01').animate({left:'-100%'},1000);
$('.sl_img02').animate({left:'-200%'},1000);
$('.sl_img03').animate({left:'0%'},1000);
$('.sl_img01').animate({left:'100%'},1000);
sbtn_03();
}
function sl_Next() {
w01 = 1;
w02 = 0;
w03 = 0;
$('.sl_img03').animate({left:'-100%'},1000);
$('.sl_img01').animate({left:'0%'},1000);
$('.sl_img02').animate({left:'100%'},1000);
$('.sl_img03').animate({left:'200%'},1000);
sbtn_01();
}
function sl01 (){
w01 = 1;
w02 = 0;
w03 = 0;
$('.sl_img01').animate({left:'0%'},1000);
$('.sl_img02').animate({left:'100%'},1000);
$('.sl_img03').animate({left:'200%'},1000);
sbtn_01();
}
function sl02 (){
w01 = 0;
w02 = 1;
w03 = 0;
$('.sl_img01').animate({left:'-100%'},1000);
$('.sl_img02').animate({left:'0%'},1000);
$('.sl_img03').animate({left:'100%'},1000);
sbtn_02();
}
function sl03 (){
w01 = 0;
w02 = 0;
w03 = 1;
$('.sl_img01').animate({left:'-200%'},1000);
$('.sl_img02').animate({left:'-100%'},1000);
$('.sl_img03').animate({left:'0%'},1000);
sbtn_03();
}
function sbtn_01() {
$('.s_btn>li:nth-child(1)>a').css('background','#c00');
$('.s_btn>li:nth-child(2)>a').css('background','#999');
$('.s_btn>li:nth-child(3)>a').css('background','#999');
}
function sbtn_02() {
$('.s_btn>li:nth-child(1)>a').css('background','#999');
$('.s_btn>li:nth-child(2)>a').css('background','#c00');
$('.s_btn>li:nth-child(3)>a').css('background','#999');
}
function sbtn_03(){
$('.s_btn>li:nth-child(1)>a').css('background','#999');
$('.s_btn>li:nth-child(2)>a').css('background','#999');
$('.s_btn>li:nth-child(3)>a').css('background','#c00');
}
});
</script>
<div id="wrap">
<div class="wrap_abs_slider">
<div class="wrap_sl_rel">
<img class="sl_img01" src="img/1.jpg" alt="">
<img class="sl_img02" src="img/2.jpg" alt="">
<img class="sl_img03" src="img/3.jpg" alt="">
</div>
</div>
<div class="wrap_abs_con">
<div class="wrap_con_rel">
<button class="left">left</button>
<button class="right">right</button>
<ul class="s_btn">
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
</ul>
</div>
</div>
</div>
</body>
</html>
- [2016/11/01] 묻고답하기 wrap으로 감싼 부분이 height 100퍼센트가 원래 안되나요...? *4
- [2016/04/15] 묻고답하기 네비게이션바 관련 코딩 도움 부탁드립니다
댓글 0
글쓴이 | 제목 | 최종 글 |
---|---|---|
XE | 공지 글 쓰기,삭제 운영방식 변경 공지 [16] | 2019.03.05 by 남기남 |
알싸라비아콜롬비아당 | 홈페이지 권한설정에 따른 에러 [1] | 2018.08.12 by sejin7940 |
댑펑 | 추가 질문드립니다. 서버 접속 문제 [1] | 2018.08.02 by Luatic™ |
인천한량 |
ms_m_board 의카카오 링크 구버전앱 링크전송 오류 문제로 도움을 청합니다.
[4]
![]() | 2018.07.19 by 인천한량 |
인천한량 | 모바일 파일첨부 장애와 파일용량제한에 대한 질문 입니다. [2] | 2018.07.19 by 인천한량 |
블맨 | 라즈베리파이 라즈비안에 XE설치 | |
boss | 레이아웃 엉망이 됐는데 어떻게 수정하나요? [1] | 2018.06.28 by 디자인클립 |
잡순이 |
HTTP ERROR 500 오류
![]() | |
boss | HTTP 500 내부 서버 오류 [1] | 2018.06.23 by 기진곰 |
아티자인 | HTTP 500 내부 서버 오류 [1] | 2018.06.19 by 너에게제공 |
가르송 | 카카오톡 api가 바꼈네요 ㅠㅠ | |
tosky**** |
레이아웃 수정 메뉴바 하단 간격 수정 ㅠㅠ
![]() | |
안준근 | 홈페이지 회원가입시 HTTP500 에러문제 [2] | 2018.05.11 by 안준근 |
마리 | 오류 [1] | 2018.04.12 by sejin7940 |
kamue**** |
데이터 마이그레이션을 데이터 추출 오류 ㅠㅠ
[4]
![]() | 2018.03.29 by kamue**** |
원자인 |
게시판 목록 추가 및 수정
![]() | |
장병훈 | 누리고 장바구니에서 결제하기 클릭시 http 500 에러 [1] | 2018.02.07 by HowtoXE |
이음 | HTTP 500 내부 서버 오류 | |
이음 | HTTP 500 내부 서버 오류 문의드립니다. | |
h****c555c | xe설치 관련문의 [1] | 2018.01.31 by Ansi™ |
절대권력 | 처음설치후 HTP500 에러 문제 [2] | 2018.01.27 by 절대권력 |