← 一覧へ

Modal / 18 ウォーターカラー|Watercolor

デザイン見本

複数重ねた`radial-gradient`(円形グラデーション)を`@keyframes`で回転、拡縮させることで、水彩絵の具がにじむようなアナログ表現を再現しています。

実装コード

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

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

<!-- モーダル本体 -->
<div class="modal">
  <div class="modal-content">
    <p>【Watercolor Modal】</p>
    <p>水彩画のような柔らかいモーダルウィンドウです。</p>
    <button class="close-btn">Close</button>
  </div>
</div>
CSS
/* 開くボタンのスタイル */
.modal-button {
  padding: 15px 30px;
  background: linear-gradient(135deg, #E91E63 0%, #9C27B0 25%, #3F51B5 50%, #2196F3 75%, #00BCD4 100%);
  color: #fff;
  border: none;
  border-radius: 30px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(233, 30, 99, 0.3);
  position: relative;
  overflow: hidden;
}

.modal-button:hover {
  background: linear-gradient(135deg, #00BCD4 0%, #2196F3 25%, #3F51B5 50%, #9C27B0 75%, #E91E63 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(233, 30, 99, 0.4);
}

/* 背景マスクのスタイル */
.mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(233, 30, 99, 0.2);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

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

/* モーダル本体のスタイル */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 25%, #90CAF9 50%, #64B5F6 75%, #42A5F5 100%);
  padding: 40px;
  border-radius: 20px;
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  max-width: 500px;
  width: 90%;
  box-shadow: 0 15px 35px rgba(66, 165, 245, 0.2);
  border: 2px solid #2196F3;
  overflow: hidden;
}

.modal.appear {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

/* 水彩のふわっとしたにじみ */
.modal::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(circle at 20% 20%, rgba(33, 150, 243, 0.3) 0%, transparent 60%),
    radial-gradient(circle at 80% 80%, rgba(100, 181, 246, 0.2) 0%, transparent 70%),
    radial-gradient(circle at 40% 60%, rgba(144, 202, 249, 0.25) 0%, transparent 65%),
    radial-gradient(circle at 60% 30%, rgba(187, 222, 251, 0.2) 0%, transparent 55%);
  animation: watercolorFlow 12s ease-in-out infinite;
  pointer-events: none;
}

/* 光の揺らめき */
.modal::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%),
    linear-gradient(-45deg, transparent 40%, rgba(255, 255, 255, 0.05) 60%, transparent 80%);
  animation: watercolorShimmer 8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes watercolorFlow {
  0%, 100% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    opacity: 0.8;
  }
  25% {
    transform: translate(15px, -10px) scale(1.2) rotate(45deg);
    opacity: 1;
  }
  50% {
    transform: translate(-8px, 12px) scale(0.9) rotate(90deg);
    opacity: 0.6;
  }
  75% {
    transform: translate(-12px, -8px) scale(1.1) rotate(135deg);
    opacity: 0.9;
  }
}

@keyframes watercolorShimmer {
  0%, 100% { opacity: 0.3; transform: translateX(0) translateY(0); }
  25% { opacity: 0.6; transform: translateX(5px) translateY(-3px); }
  50% { opacity: 0.4; transform: translateX(-3px) translateY(5px); }
  75% { opacity: 0.7; transform: translateX(-5px) translateY(-2px); }
}

.modal p {
  color: #1565C0;
  font-weight: 600;
  text-align: center;
  margin-bottom: 24px;
  position: relative;
  z-index: 2;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

/* 閉じるボタンのスタイル */
.close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 32px;
  height: 32px;
  background: rgba(33, 150, 243, 0.9);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
  line-height: 1;
}

.close-btn:hover {
  background: rgba(66, 165, 245, 0.9);
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.4);
}
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');
  }

  function closeModal() {
    mask.classList.remove('appear');
    modal.classList.remove('appear');
  }

  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();
    }
  });
})();