← 一覧へ

Dialog / 09 3Dエフェクト|3D Effect

デザイン見本

3D Effect Dialog

3Dエフェクトと遠近法を使った立体的なダイアログです。

3Dエフェクトと遠近法を使った立体的なダイアログです。

実装コード

HTML
<button id="dialog-btn-9">3D Effect<br>Dialog</button>
                <div id="dialog-9" class="dialog">
                    <div class="dialog-content">
                        <div class="three-d-header">
                            <span>3D Effect Dialog</span>
                        </div>
                        <div class="three-d-body">
                            <p>3Dエフェクトと遠近法を使った立体的なダイアログです。</p>
                        </div>
                        <div class="three-d-footer">
                            <button class="three-d-btn">Continue</button>
                        </div>
                    </div>
                </div>
CSS
#dialog-btn-9 {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    min-width: 200px;
    min-height: 60px;
    display: inline-block;
    text-align: center;
    line-height: 1.4;
    vertical-align: middle;
}

#dialog-btn-9:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

#dialog-9 {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn-9 0.3s;
}

#dialog-9 .dialog-content {
    width: 80%;
    max-width: 500px;
    margin: 8% auto;
    background: linear-gradient(145deg, #ffffff 0%, #f0f0f0 100%);
    border-radius: 20px;
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.8),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    overflow: hidden;
    transform: perspective(1000px) rotateX(5deg);
    transition: transform 0.3s ease;
    animation: slideInFromTop-9 0.3s ease-out;
}

#dialog-9 .dialog-content:hover {
    transform: perspective(1000px) rotateX(0deg) scale(1.02);
}

#dialog-9 .three-d-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px 20px;
    text-align: center;
    position: relative;
    transform: perspective(1000px) rotateX(-5deg);
    transform-origin: bottom;
}

#dialog-9 .three-d-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    animation: shimmer-9 2s infinite;
}

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

#dialog-9 .three-d-header span {
    font-size: 20px;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

#dialog-9 .three-d-body {
    padding: 25px 20px;
    background: rgba(255, 255, 255, 0.8);
    position: relative;
}

#dialog-9 .three-d-body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.1), transparent);
}

#dialog-9 .three-d-body p {
    margin: 0;
    line-height: 1.6;
    color: #555;
    font-size: 16px;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

#dialog-9 .three-d-footer {
    padding: 20px;
    text-align: center;
    background: linear-gradient(145deg, #f8f9fa 0%, #e9ecef 100%);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    position: relative;
}

#dialog-9 .three-d-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
}

#dialog-9 .three-d-btn {
    background: linear-gradient(145deg, #007bff 0%, #0056b3 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow:
        0 4px 15px rgba(0, 123, 255, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

#dialog-9 .three-d-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

#dialog-9 .three-d-btn:hover::before {
    left: 100%;
}

#dialog-9 .three-d-btn:hover {
    transform: translateY(-2px);
    box-shadow:
        0 6px 20px rgba(0, 123, 255, 0.4),
        0 4px 8px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

#dialog-9 .three-d-btn:active {
    transform: translateY(0);
    box-shadow:
        0 2px 10px rgba(0, 123, 255, 0.3),
        0 1px 2px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

@keyframes fadeIn-9 {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInFromTop-9 {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    #dialog-9 .dialog-content {
        width: 90%;
        margin: 15% auto;
    }

    #dialog-9 .three-d-header span {
        font-size: 18px;
    }

    #dialog-9 .three-d-body p {
        font-size: 14px;
    }
}
JS
(function () {
      var btn = document.getElementById('dialog-btn-9');
      var dialog = document.getElementById('dialog-9');
      var closeBtns = dialog ? dialog.querySelectorAll('button') : [];

      if (!btn || !dialog) return;

      function openDialog() {
        dialog.style.display = 'block';
        document.body.style.overflow = 'hidden';
      }

      function closeDialog() {
        dialog.style.display = 'none';
        document.body.style.overflow = 'auto';
      }

      btn.addEventListener('click', openDialog);
      
      closeBtns.forEach(function(b) { b.addEventListener('click', closeDialog); });

      dialog.addEventListener('click', function (e) {
        if (e.target === dialog) {
          closeDialog();
        }
      });

      document.addEventListener('keydown', function (e) {
        if (e.key === 'Escape' && dialog.style.display === 'block') {
          closeDialog();
        }
      });
    })();