← 一覧へ

Tab Menu / 17 サークルホバー|Circle Hover

デザイン見本

  • 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 {
  overflow: hidden;
  border-radius: 20px;
  position: relative;
}

.tab-container ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 30px;
  position: relative;
}

.tab-container ul li {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  color: #666;
  font-weight: 600;
  font-size: 18px;
  background: transparent;
  border: 3px solid transparent;
  overflow: hidden;
  border-radius: 50%;
}

.tab-container ul li::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(102, 126, 234, 0.15);
  border-radius: 50%;
  transform: scale(0);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: -1;
}

.tab-container ul li:hover::before {
  transform: scale(0.8);
}

.tab-container ul li.selected {
  color: #667eea;
  border-color: transparent;
  background: transparent;
  font-weight: bold;
  transform: none;
  position: relative;
}

.tab-container ul li.selected::after {
  content: '';
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: #667eea;
  border-radius: 0;
}

.tab-container ul li:not(.selected):hover {
  color: #667eea;
  transform: translateY(-2px) scale(1.02);
}

.tab-container .tab-content {
  display: none;
  padding: 30px;
  min-height: 180px;
  background: #fff;
  color: #333;
  border-radius: 16px;
  box-shadow: 
      0 4px 16px rgba(0, 0, 0, 0.1),
      inset 0 1px 0 rgba(255, 255, 255, 0.8);
  position: relative;
  overflow: hidden;
}

.tab-container .tab-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 16px 16px 0 0;
}

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

@keyframes circleHoverFadeIn {
  from { 
      opacity: 0; 
      transform: translateY(-20px) 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');
  });
});