← 一覧へ

Popup / 04 マジカル|Magical

デザイン見本

浮遊感(float)、発光(glow)、回転(rotate)、きらめき(shimmer)など、複数のCSSアニメーションを組み合わせた幻想的なデザインです。

実装コード

HTML
<div id="popup-container-4">
  <button id="popup-btn-4">Magical</button>
</div>
<div id="popup-4" class="popup-4">
  <div class="popup-content-4">
    <p>Magical Popup</p>
    <p>魔法のような複合アニメーションのポップアップです。</p>
  </div>
</div>
CSS
/* Button Style */
#popup-btn-4 {
  cursor: pointer;
  border: none;
  padding: 12px 24px;
  border-radius: 16px;
  color: #333;
  background-color: #eee;
  font-weight: 600;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
  display: block;
  margin: 0 auto;
  width: 180px;
}

#popup-btn-4:hover {
  opacity: 0.5;
}

/* Popup Style */
.popup-4 {
  position: fixed;
  bottom: -100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  max-width: 90%;
  max-height: 90%;
}

.popup-4.active {
  opacity: 1;
  visibility: visible;
  bottom: 20px;
  transform: translateX(-50%);
  animation: popupShowHide4 3.4s ease forwards;
}

@keyframes popupShowHide4 {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(100%);
  }
  20% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  80% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(100%);
  }
}

.popup-content-4 {
  background: white;
  padding: 30px;
  border-radius: 12px;
  text-align: center;
  position: relative;
  min-width: 300px;
  box-shadow: 0 25px 50px rgba(111, 66, 193, 0.2);
  border: 2px solid #6f42c1;
  animation: glow 2s ease-in-out infinite alternate, float 3s ease-in-out infinite;
  overflow: hidden;
}

@keyframes glow {
  from {
    box-shadow: 0 25px 50px rgba(111, 66, 193, 0.2);
  }
  to {
    box-shadow: 0 25px 50px rgba(111, 66, 193, 0.4), 0 0 20px rgba(111, 66, 193, 0.3);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-5px);
  }
}

.popup-content-4::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(from 0deg, transparent, rgba(111, 66, 193, 0.1), transparent, rgba(111, 66, 193, 0.1), transparent);
  animation: rotate 4s linear infinite;
  z-index: -1;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.popup-content-4::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent 30%, rgba(111, 66, 193, 0.05) 50%, transparent 70%);
  animation: shimmer 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.popup-content-4 p:first-child {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 15px;
  color: #6f42c1;
  animation: textGlow 2s ease-in-out infinite alternate, bounce 2s ease-in-out infinite;
  position: relative;
}

@keyframes textGlow {
  from {
    text-shadow: 0 0 5px rgba(111, 66, 193, 0.3);
  }
  to {
    text-shadow: 0 0 10px rgba(111, 66, 193, 0.6), 0 0 20px rgba(111, 66, 193, 0.4);
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

.popup-content-4 p:last-of-type {
  font-size: 16px;
  color: #666;
  margin-bottom: 25px;
  line-height: 1.6;
  animation: fadeInOut 3s ease-in-out infinite;
}

@keyframes fadeInOut {
  0%, 100% {
    opacity: 0.7;
  }
  50% {
    opacity: 1;
  }
}
JS
var btn = document.getElementById('popup-btn-4');
var popup = document.getElementById('popup-4');

if (btn && popup) {
  btn.addEventListener('click', function () {
    popup.classList.add('active');
  });

  popup.addEventListener('animationend', function () {
    popup.classList.remove('active');
  });
}