Tab Menu / 20 ミニマル太字|Minimal Bold
デザイン見本
- 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">
Tab 1 のコンテンツ
</div>
<div class="tab-content" id="tab-2">
Tab 2 のコンテンツ
</div>
<div class="tab-content" id="tab-3">
Tab 3 のコンテンツ
</div>
</div>
CSS
.tab-container ul {
margin: 0;
padding: 0;
list-style: none;
display: flex;
border-bottom: none;
}
.tab-container ul li {
flex: 1;
padding: 16px 24px;
text-align: center;
cursor: pointer;
transition: all 0.3s ease;
position: relative;
color: #999;
font-weight: 300;
letter-spacing: 0.5px;
font-size: 14px;
}
.tab-container ul li.selected {
color: #333;
font-weight: 700;
font-size: 16px;
}
.tab-container ul li:not(.selected):hover {
color: #333;
}
.tab-container .tab-content {
display: none;
padding: 32px 24px;
min-height: 150px;
color: #333;
line-height: 1.6;
}
.tab-container .tab-content.selected {
display: block;
animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
JS
const tabContainer = document.querySelector('.tab-container');
const tabMenuItems = tabContainer.querySelectorAll('ul li');
const tabContents = tabContainer.querySelectorAll('.tab-content');
tabMenuItems.forEach(tabMenuItem => {
tabMenuItem.addEventListener('click', () => {
tabMenuItems.forEach(item => {
item.classList.remove('selected');
});
tabMenuItem.classList.add('selected');
tabContents.forEach(tabContent => {
tabContent.classList.remove('selected');
});
document.getElementById(tabMenuItem.dataset.id).classList.add('selected');
});
});