← 一覧へ

Tab Menu / 24 アウトライン|Outline

デザイン見本

  • 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.

アウトライン(輪郭線)を強調した、透明感のあるモダンなデザインです。グラデーションとぼかし効果(Glassmorphism)を組み合わせ、先進的で軽やかな印象を与えます。スタートアップやSaaSのランディングページなどに最適です。

実装コード

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 {
  position: relative;
}

.tab-container ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  border-bottom: none;
  position: relative;
  z-index: 2;
}

.tab-container ul li {
  flex: 1;
  padding: 18px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  color: #6c757d;
  font-weight: 500;
  letter-spacing: 0.5px;
  border: 3px solid transparent;
  border-radius: 12px 12px 0 0;
  margin: 0 2px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
}

.tab-container ul li::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, 
      rgba(102, 126, 234, 0.1) 0%, 
      rgba(118, 75, 162, 0.1) 100%);
  opacity: 0;
  transition: opacity 0.4s ease;
  border-radius: 12px 12px 0 0;
}

.tab-container ul li:hover::before {
  opacity: 1;
}

.tab-container ul li.selected {
  color: #fff;
  font-weight: 600;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: 3px solid #667eea;
  border-bottom: none;
  box-shadow: 
      0 -4px 16px rgba(102, 126, 234, 0.3),
      0 0 0 1px rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  z-index: 3;
}

.tab-container ul li.selected::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 0 0 3px 3px;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.tab-container ul li:not(.selected):hover {
  color: #667eea;
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(102, 126, 234, 0.3);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.tab-container .tab-content {
  display: none;
  padding: 32px;
  min-height: 180px;
  color: #495057;
  line-height: 1.7;
  border: 3px solid #667eea;
  border-top: none;
  border-radius: 0 0 16px 16px;
  background: #fff;
  position: relative;
  z-index: 2;
  margin-top: -3px;
  margin-left: 2px;
  margin-right: 2px;
}

.tab-container .tab-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea, #764ba2, #667eea);
  border-radius: 0 0 4px 4px;
  animation: gradientFlow 3s ease-in-out infinite;
}

@keyframes gradientFlow {
  0%, 100% { 
      background: linear-gradient(90deg, #667eea, #764ba2, #667eea);
  }
  50% { 
      background: linear-gradient(90deg, #764ba2, #667eea, #764ba2);
  }
}

.tab-container .tab-content.selected {
  display: block;
  animation: outlineFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes outlineFadeIn {
  from { 
      opacity: 0; 
      transform: translateY(-15px) scale(0.98);
      filter: blur(2px);
  }
  to { 
      opacity: 1; 
      transform: translateY(0) scale(1);
      filter: blur(0);
  }
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
  .tab-container ul li {
      padding: 14px 16px;
      font-size: 14px;
  }
  
  .tab-container .tab-content {
      padding: 24px;
      min-height: 150px;
  }
}
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');
  });
});