제이쿼리 멀티탭 구현
멀티탭 구현
See the Pen 멀티탭구현 by yoonbitnara (@yoonbitnara) on CodePen.
상세코드
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>멀티탭 구현</h1>
<div id="wrap">
<div id="tabs">
<button type="button" class="selected">공지사항</button>
<button type="button" class="">갤러리</button>
</div>
</div>
</body>
</html>
CSS
* {
box-sizing: border-box;
}
div#wrap {
border: 1px solid #000;
width: 500px;
margin: 20px auto;
padding: 40px;
}
h1 {
border: 1px solid #000;
text-align: center;
margin: 40px auto;
width: 500px;
}
button {
border: 1px solid #aaa;
font-size: 24px;
font-weight: bold;
padding: 2px 10px;
border-right: none;
border-left: none;
cursor: pointer;
}
div#tabs {
display: flex;
}
button.selected {
border-right: 1px solid #aaa;
border-left: 1px solid #aaa;
background-color: #fff;
}
button:not(.selected) {
border-right: 1px solid #aaa;
}
jQuery
$("button").click(function () {
$("button").css({ "background-color": "#fff" });
$(this).css({ "background-color": "rgb(239, 239, 239)" });
});
Leave a comment