モーダルウィンドウ:ホログラフィック|Modal Window: Holographic

HTML
<div class="container">
    <button class="modal-button">Holographic Modal</button>
</div>

<div class="mask"></div>
<div class="modal">
    <div class="modal-content">
        <p>[Holographic Modal]</p>
        <p>A futuristic holographic modal window with rainbow reflections and prismatic effects. Features iridescent colors that shift and shimmer like a real hologram.</p>
        <div class="close-btn-container">
            <button class="close-btn">Close</button>
        </div>
    </div>
</div>
CSS
.container {
    text-align: center;
}

.modal-button {
    padding: 15px 30px;
    background: linear-gradient(45deg, #ff0080, #ff8c00, #40e0d0, #ee82ee, #ff0080);
    background-size: 400% 400%;
    color: #fff;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: holographicShift 3s ease infinite;
    box-shadow: 0 4px 15px rgba(255, 0, 128, 0.3);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

@keyframes holographicShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.modal-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 0, 128, 0.5);
    animation: holographicShift 1.5s ease infinite;
}

.mask {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 0, 128, 0.3);
    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, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 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%;
    backdrop-filter: blur(20px);
    border: 2px solid transparent;
    background-clip: padding-box;
    overflow: hidden;
}

.modal::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(45deg, #ff0080, #ff8c00, #40e0d0, #ee82ee, #ff0080);
    background-size: 400% 400%;
    animation: holographicShift 4s ease infinite;
    border-radius: 20px;
    z-index: -1;
    margin: -2px;
}

.modal::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    border-radius: 20px;
    z-index: -1;
    margin: 2px;
}

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

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

.close-btn {
    padding: 12px 24px;
    background: linear-gradient(45deg, #ff0080, #ff8c00);
    color: #fff;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: block;
    margin: 0 auto;
    position: relative;
    z-index: 2;
    box-shadow: 0 4px 15px rgba(255, 0, 128, 0.3);
}

.close-btn:hover {
    background: linear-gradient(45deg, #ff8c00, #40e0d0);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 0, 128, 0.4);
}

@media (max-width: 768px) {
    .modal {
        width: 95%;
        padding: 20px;
    }
    
    .modal p {
        font-size: 14px;
    }
    
    .modal-button {
        font-size: 14px;
        padding: 10px 20px;
    }
}
JavaScript
document.addEventListener('DOMContentLoaded', function() {
    const modalBtn = document.querySelector('.modal-button');
    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();
    });
    
    // ESCキーでモーダルを閉じる
    document.addEventListener('keydown', function(e) {
        if (e.key === 'Escape') {
            closeModal();
        }
    });
    
    // モーダルを閉じる関数
    function closeModal() {
        mask.classList.remove('appear');
        modal.classList.remove('appear');
    }
    
    // ホログラフィックエフェクト強化
    modal.addEventListener('mouseenter', function() {
        this.style.animation = 'holographicShift 2s ease infinite';
    });
    
    modal.addEventListener('mouseleave', function() {
        this.style.animation = 'none';
    });
});
よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!
目次