アコーディオン:3D立体|Accordion: Three-Dimension

  • 3D dimensional design
  • Depth effect with perspective
  • 3D rotation animation on hover
  • Press animation on click
  • Modern and premium design
HTML
<div class="container">
    <div class="btn-box">
        <button data-default-text="3D Accordion" data-open-text="Close">3D Accordion</button>
    </div>
    <div class="more">
        <ul>
            <li>3D dimensional design</li>
            <li>Depth effect with perspective</li>
            <li>3D rotation animation on hover</li>
            <li>Press animation on click</li>
            <li>Modern and premium design</li>
        </ul>
    </div>
</div>
CSS
@keyframes elegantSlideIn {
  0% {
    opacity: 0;
    transform: translateY(-15px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes buttonPress {
  0% {
    transform: perspective(1000px) rotateX(0deg) translateY(0);
  }
  50% {
    transform: perspective(1000px) rotateX(5deg) translateY(2px);
  }
  100% {
    transform: perspective(1000px) rotateX(0deg) translateY(0);
  }
}

@keyframes listItemFadeIn {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

body {
  background: #f5f5f5;
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 20px;
}

.container {
  perspective: 1000px;
  margin-bottom: 30px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.container .btn-box button {
  width: 100%;
  padding: 22px 28px;
  background: linear-gradient(145deg, #ffffff, #e6e6e6);
  border: none;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 700;
  color: #333;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-align: left;
  position: relative;
  box-shadow: 
    0 8px 16px rgba(0, 0, 0, 0.1),
    0 4px 8px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transform-style: preserve-3d;
}

.container .btn-box button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(145deg, #f0f0f0, #ffffff);
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
}

.container .btn-box button:hover {
  transform: perspective(1000px) rotateX(-2deg) translateY(-3px);
  box-shadow: 
    0 15px 30px rgba(0, 0, 0, 0.15),
    0 8px 16px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  color: #2196f3;
}

.container .btn-box button:active {
  animation: buttonPress 0.2s ease;
  box-shadow: 
    0 4px 8px rgba(0, 0, 0, 0.1),
    0 2px 4px rgba(0, 0, 0, 0.06),
    inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.container .more {
  max-height: 0;
  overflow: hidden;
  transition: all 0.3s ease-out;
  background: linear-gradient(145deg, #f8f9fa, #ffffff);
  border-radius: 0 0 20px 20px;
  box-shadow: 
    0 8px 16px rgba(0, 0, 0, 0.1),
    0 4px 8px rgba(0, 0, 0, 0.06);
  transform-style: preserve-3d;
  margin-top: -10px;
  position: relative;
  z-index: 1;
}

.container .more::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.1), transparent);
}

.container .more.appear {
  max-height: 300px;
  animation: elegantSlideIn 0.3s ease-out;
}

.container .more ul {
  list-style: none;
  padding: 25px 28px 28px;
  margin: 0;
}

.container .more li {
  padding: 15px 0;
  color: #555;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  font-weight: 500;
  position: relative;
  transition: all 0.3s ease;
  opacity: 0;
  transform: translateY(10px);
  animation: listItemFadeIn 0.4s ease-out forwards;
}

.container .more.appear li:nth-child(1) { animation-delay: 0.1s; }
.container .more.appear li:nth-child(2) { animation-delay: 0.15s; }
.container .more.appear li:nth-child(3) { animation-delay: 0.2s; }
.container .more.appear li:nth-child(4) { animation-delay: 0.25s; }
.container .more.appear li:nth-child(5) { animation-delay: 0.3s; }

.container .more li::before {
  content: '▶';
  position: absolute;
  left: -15px;
  top: 15px;
  color: #2196f3;
  font-size: 12px;
  opacity: 0;
  transition: all 0.3s ease;
  transform: translateX(-5px);
}

.container .more li:hover {
  color: #2196f3;
  padding-left: 10px;
  transform: translateX(5px);
}

.container .more li:hover::before {
  opacity: 1;
  transform: translateX(0);
}

.container .more li:last-child {
  border-bottom: none;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .container .btn-box button {
    font-size: 14px;
    padding: 18px 22px;
    border-radius: 15px;
  }
  
  .container .more {
    border-radius: 0 0 15px 15px;
  }
  
  .container .more ul {
    padding: 20px 22px 22px;
  }
  
  .container .more li {
    padding: 12px 0;
  }
}
JavaScript
document.addEventListener('DOMContentLoaded', function() {
    const button = document.querySelector('.btn-box button');
    const content = document.querySelector('.more');
    
    button.addEventListener('click', function() {
        content.classList.toggle('appear');
        
        // ボタンテキストの切り替え
        if (content.classList.contains('appear')) {
            this.textContent = this.dataset.openText || 'Close';
        } else {
            this.textContent = this.dataset.defaultText;
        }
    });
});
よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!
目次