モーダルウィンドウ:フューチャリスティック|Modal Window: Futuristic

HTML
<div class="container">
    <h1>Futuristic Modal</h1>
    <button class="modal-btn">Open Futuristic Modal</button>
</div>
<div class="mask"></div>
<div class="modal">
    <div class="modal-content">
        <p>[Futuristic Modal]</p>
        <p>A modal window with futuristic gradients and glow effects, reminiscent of a science fiction movie.</p>
        <div class="close-btn-container">
            <button class="close-btn">Close</button>
        </div>
    </div>
</div>
CSS
body {
    font-family: 'Arial', sans-serif;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    text-align: center;
    color: #00c3ff;
}

h1 {
    margin-bottom: 30px;
    font-size: 2.5em;
    text-shadow: 0 0 8px #00c3ff, 0 0 2px #ffff1c;
}

.modal-btn {
  padding: 15px 30px;
  background: linear-gradient(90deg, #00c3ff 0%, #ffff1c 100%);
  color: #222;
  border: none;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 195, 255, 0.2);
  text-shadow: 0 0 8px #00c3ff, 0 0 2px #ffff1c;
}

.modal-btn:hover {
  background: linear-gradient(90deg, #ffff1c 0%, #00c3ff 100%);
  color: #00c3ff;
}

.mask {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 195, 255, 0.5);
  z-index: 1000;
  opacity: 0; visibility: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(8px);
}

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

.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: linear-gradient(135deg, #232526 0%, #414345 100%);
  padding: 40px;
  border-radius: 24px;
  z-index: 1001;
  opacity: 0; visibility: hidden;
  transition: all 0.4s cubic-bezier(.68,-0.55,.27,1.55);
  max-width: 500px; width: 90%;
  box-shadow: 0 0 40px 8px #00c3ff99, 0 0 0 2px #ffff1c99;
  border: 2px solid #00c3ff;
}

.modal.appear {
  opacity: 1; visibility: visible;
  transform: translate(-50%, -50%) scale(1);
  box-shadow: 0 0 60px 16px #00c3ffcc, 0 0 0 4px #ffff1ccc;
}

.modal p {
  color: #ffff1c;
  font-weight: 700;
  text-align: center;
  margin-bottom: 24px;
  text-shadow: 0 0 8px #00c3ff, 0 0 2px #ffff1c;
}

.close-btn {
  padding: 12px 24px;
  background: #00c3ff;
  color: #232526;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.3s;
  display: block;
  margin: 0 auto;
  box-shadow: 0 0 8px #00c3ff99;
}

.close-btn:hover {
  background: #ffff1c;
  color: #00c3ff;
  box-shadow: 0 0 16px #ffff1c99;
}
JavaScript
document.addEventListener('DOMContentLoaded', function() {
    const modalBtn = document.querySelector('.modal-btn');
    const mask = document.querySelector('.mask');
    const modal = document.querySelector('.modal');
    const closeBtn = modal.querySelector('.close-btn');
    modalBtn.addEventListener('click', () => {
        mask.classList.add('appear');
        modal.classList.add('appear');
    });
    mask.addEventListener('click', () => {
        closeModal();
    });
    closeBtn.addEventListener('click', () => {
        closeModal();
    });
    document.addEventListener('keydown', function(e) {
        if (e.key === 'Escape') {
            closeModal();
        }
    });
    function closeModal() {
        mask.classList.remove('appear');
        modal.classList.remove('appear');
    }
});
よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!
目次