Tab Menu / 32 チケット|Ticket
デザイン見本
- Tab 1
- Tab 2
- Tab 3
Good morning. This is the content of Tab 1.
Hello. This is the content of Tab 2.
Good evening. This is the content of Tab 3.
ヴィンテージなコンサートチケットをイメージしたデザインです。クリーム色のパーチメント地に破線の区切り線、選択時はクリムゾンレッドに変わる「刻印」のような演出が特徴です。コンテンツエリアにも薄いボーダーフレームを配置し、本物のチケットに近い質感を表現しています。
実装コード
HTML
<div class="tab-container">
<ul>
<li class="selected" data-id="tab-1">Tab 1</li>
<li data-id="tab-2">Tab 2</li>
<li data-id="tab-3">Tab 3</li>
</ul>
<div class="tab-content selected" id="tab-1">
Good morning. This is the content of Tab 1.
</div>
<div class="tab-content" id="tab-2">
Hello. This is the content of Tab 2.
</div>
<div class="tab-content" id="tab-3">
Good evening. This is the content of Tab 3.
</div>
</div>
CSS
.tab-container {
border: 2px solid #c9a96e;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 12px rgba(139, 90, 43, 0.15);
}
.tab-container ul {
margin: 0;
padding: 0;
list-style: none;
display: flex;
background: #fdf6e3;
border-bottom: 2px dashed #c9a96e;
}
.tab-container ul li {
flex: 1;
padding: 16px 12px;
text-align: center;
cursor: pointer;
color: #8b6914;
font-size: 13px;
letter-spacing: 2px;
text-transform: uppercase;
font-weight: 600;
position: relative;
border-right: 2px dashed #c9a96e;
background-color: #fdf6e3;
border-top: 3px solid transparent;
transition: background-color 0.3s ease, color 0.3s ease;
}
.tab-container ul li:last-child {
border-right: none;
}
.tab-container ul li:not(.selected):hover {
background-color: #f5ead4;
}
.tab-container ul li.selected {
background-color: #7a1515;
color: #fdf6e3;
border-top-color: #5a0f0f;
}
.tab-container .tab-content {
display: none;
padding: 28px 24px;
min-height: 150px;
background-color: #fdf6e3;
color: #5a3e12;
line-height: 1.8;
font-size: 14px;
position: relative;
}
.tab-container .tab-content::before {
content: '';
position: absolute;
top: 10px;
left: 14px;
right: 14px;
bottom: 10px;
border: 1px solid rgba(201, 169, 110, 0.4);
border-radius: 4px;
pointer-events: none;
}
.tab-container .tab-content.selected {
display: block;
animation: ticketReveal 0.4s ease-out;
}
@keyframes ticketReveal {
from { opacity: 0; transform: translateY(-10px); }
to { opacity: 1; transform: translateY(0); }
}
JS
(function () {
'use strict';
document.addEventListener('DOMContentLoaded', function () {
var container = document.querySelector('.tab-container');
if (!container) return;
var items = container.querySelectorAll('ul li');
var contents = container.querySelectorAll('.tab-content');
items.forEach(function (item) {
item.addEventListener('click', function () {
items.forEach(function (i) { i.classList.remove('selected'); });
contents.forEach(function (c) { c.classList.remove('selected'); });
item.classList.add('selected');
var target = document.getElementById(item.getAttribute('data-id'));
if (target) target.classList.add('selected');
});
});
});
})();