[jQuery] 제이쿼리 간단탭
페이지 정보
본문
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>tabs demo</title>
<style>
#tabs ul {margin:0; padding:0; list-style:none;}
#tabs .tab01 {position:relative; padding-top:31px;}
#tabs .tab01>li>a {
display:block;
position:absolute;
top:0;
width:95px;
height:30px;
line-height:30px;
text-align:center;
background:#0099CC;
color:#fff;
border:1px solid #0099CC;
border-bottom:0;
}
#tabs .tab01>li.on>a {background:#f0f0f0;border:1px solid #f0f0f0; color:#333;}
#tabs .tab01>li:first-child>a {left:0;}
#tabs .tab01>li+li>a {left:100px;}
#tabs .tab01>li+li+li>a {left:200px;}
#tabs .tab01>li>div {height:0; overflow:hidden; position:absolute;}
#tabs .tab01>li.on>div {height:auto; position:static; border:1px solid #f0f0f0; background:#f0f0f0;padding:10px;}
</style>
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
</head>
<body>
<div id="tabs">
<ul class="tab01">
<li class="on">
<a href="#">탭메뉴 1</a>
<div>
내용 1
</div>
</li>
<li>
<a href="#">탭메뉴 2</a>
<div>
내용 2
</div>
</li>
<li>
<a href="#">탭메뉴 3</a>
<div>
내용 3
</div>
</li>
</ul>
</div>
<script>
$( "#tabs .tab01>li>a" ).click(function() {
$(this).parent().addClass("on").siblings().removeClass("on");
return false;
});
</script>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>tabs demo</title>
<style>
#tabs ul {margin:0; padding:0; list-style:none;}
#tabs .tab01 {position:relative; padding-top:31px;}
#tabs .tab01>li>a {
display:block;
position:absolute;
top:0;
width:95px;
height:30px;
line-height:30px;
text-align:center;
background:#0099CC;
color:#fff;
border:1px solid #0099CC;
border-bottom:0;
}
#tabs .tab01>li.on>a {background:#f0f0f0;border:1px solid #f0f0f0; color:#333;}
#tabs .tab01>li:first-child>a {left:0;}
#tabs .tab01>li+li>a {left:100px;}
#tabs .tab01>li+li+li>a {left:200px;}
#tabs .tab01>li>div {height:0; overflow:hidden; position:absolute;}
#tabs .tab01>li.on>div {height:auto; position:static; border:1px solid #f0f0f0; background:#f0f0f0;padding:10px;}
</style>
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
</head>
<body>
<div id="tabs">
<ul class="tab01">
<li class="on">
<a href="#">탭메뉴 1</a>
<div>
내용 1
</div>
</li>
<li>
<a href="#">탭메뉴 2</a>
<div>
내용 2
</div>
</li>
<li>
<a href="#">탭메뉴 3</a>
<div>
내용 3
</div>
</li>
</ul>
</div>
<script>
$( "#tabs .tab01>li>a" ).click(function() {
$(this).parent().addClass("on").siblings().removeClass("on");
return false;
});
</script>
</body>
</html>
추천0
관련링크
-
http://{url}/tip/tab01.html
1894회 연결
댓글목록
등록된 댓글이 없습니다.