← 一覧へ

Modal / 29 オーロラ フルスクリーン|Aurora Fullscreen

デザイン見本

複数色のグラデーション(linear-gradient)を大きく設定し、@keyframesにより背景位置(background-position)をゆっくり動かすことで、オーロラのような幻想的な動的背景を実装したフルスクリーンモーダルです。

実装コード

HTML
<!-- モーダルを開くボタン -->
<button class="modal-button">Aurora Fullscreen Modal</button>

<!-- モーダルの背景マスク -->
<div class="mask"></div>

<!-- モーダル本体(フルスクリーン対応クラスを追加) -->
<div class="modal fullscreen">
  <div class="modal-content">
    <div class="close-btn-container">
      <button class="close-btn">×</button>
    </div>
    <div class="fullscreen-content">
      <p>【Aurora Fullscreen Modal】</p>
      <p>オーロラのように色がゆっくりと変化する、幻想的なアニメーション背景のフルスクリーンモーダルです。CSSのキーフレームアニメーションで無限に色が移り変わります。</p>
      <div class="close-btn-container">
        <button class="close-btn">DISMISS</button>
      </div>
    </div>
  </div>
</div>
CSS
/* 開くボタンのスタイル */
.modal-button {
  padding: 15px 30px;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.modal-button:hover {
  background: #1e293b;
  border-color: #475569;
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4), 0 0 10px rgba(139, 92, 246, 0.3);
}

/* 背景マスクのスタイル */
.mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.8);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.5s ease;
}

.mask.appear {
  opacity: 1;
  visibility: visible;
}

/* オーロラフルスクリーンモーダル本体 */
.modal.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* 複数色のグラデーション */
  background: linear-gradient(-45deg, #0f172a, #4c1d95, #047857, #0f172a);
  /* 背景サイズを大きくして動きを持たせる */
  background-size: 400% 400%;
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
}

/* 表示されたらアニメーションをトリガー */
.modal.fullscreen.appear {
  opacity: 1;
  visibility: visible;
  animation: auroraBackground 15s ease infinite;
}

/* 背景を動かすキーフレーム */
@keyframes auroraBackground {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* コンテンツを包む半透明レイヤー */
.modal-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  /* 視認性を上げるための薄いオーバーレイとブラー効果 */
  background: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(8px);
}

/* 右上が絶対配置で「×」ボタン */
.modal.fullscreen > .modal-content > .close-btn-container {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 10;
}

.modal.fullscreen > .modal-content > .close-btn-container .close-btn {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  font-size: 24px;
  font-weight: 300;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.modal.fullscreen > .modal-content > .close-btn-container .close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  transform: rotate(90deg);
}

/* モーダルコンテンツ中央揃え */
.fullscreen-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  text-align: center;
}

.modal p {
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.15rem;
  line-height: 1.7;
  margin-bottom: 25px;
  max-width: 600px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* 下部の「CLOSE」ボタンスタイル */
.fullscreen-content .close-btn-container {
  margin-top: 30px;
}

.fullscreen-content .close-btn {
  padding: 14px 40px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 30px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-indent: 0.1em;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.5;
  min-width: 140px;
}

.fullscreen-content .close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1);
}
JS
(function () {
  var btn = document.querySelector('.modal-button');
  var mask = document.querySelector('.mask');
  var modal = document.querySelector('.modal');
  var closeBtns = document.querySelectorAll('.close-btn');

  if (!btn || !mask || !modal) return;

  function openModal() {
    mask.classList.add('appear');
    modal.classList.add('appear');
    if (modal.classList.contains('fullscreen')) {
      document.body.style.overflow = 'hidden';
    }
  }

  function closeModal() {
    mask.classList.remove('appear');
    modal.classList.remove('appear');
    if (modal.classList.contains('fullscreen')) {
      document.body.style.overflow = '';
    }
  }

  btn.addEventListener('click', openModal);
  mask.addEventListener('click', closeModal);
  closeBtns.forEach(function(b) { b.addEventListener('click', closeModal); });

  document.addEventListener('keydown', function (e) {
    if (e.key === 'Escape' && modal.classList.contains('appear')) {
      closeModal();
    }
  });
})();