Tab Menu / 13 丸ボタン|Rounded Button
デザイン見本
- 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.
カプセル型の独立したボタンを並べたような、モダンで使いやすいデザインです。選択時にボタンが浮き上がり、鮮やかなグラデーションと共にドロップシャドウが強調されます。アプリやツール系のUIに親和性が高いスタイルです。
実装コード
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 {
border-radius: 12px;
position: relative;
}
.tab-container ul {
margin: 0;
padding: 0;
list-style: none;
display: flex;
gap: 12px;
margin-bottom: 20px;
position: relative;
}
.tab-container ul li {
flex: 1;
padding: 14px 24px;
text-align: center;
cursor: pointer;
transition: all 0.3s ease;
position: relative;
color: #666;
font-weight: 500;
font-family: 'Arial', sans-serif;
background: #fff;
border: 2px solid #e0e0e0;
border-radius: 25px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
transform: translateY(0);
}
.tab-container ul li.selected {
color: #fff;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-color: #667eea;
box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
transform: translateY(-2px);
}
.tab-container ul li:not(.selected):hover {
background: #f8f9fa;
border-color: #667eea;
color: #667eea;
transform: translateY(-1px);
box-shadow: 0 3px 12px rgba(102, 126, 234, 0.2);
}
.tab-container .tab-content {
display: none;
padding: 24px;
min-height: 150px;
background: #fff;
color: #333;
border-radius: 12px;
position: relative;
}
.tab-container .tab-content.selected {
display: block;
animation: buttonFadeIn 0.4s ease;
}
@keyframes buttonFadeIn {
from {
opacity: 0;
transform: translateY(-10px) scale(0.95);
}
to {
opacity: 1;
transform: translateY(0) scale(1);
}
}
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');
});
});