← 一覧へ

Dialog / 11 フローティングカード|Floating Card

デザイン見本

Floating Card Dialog

浮遊感のあるカードデザインのダイアログボックスです。

浮遊感のあるカードデザインのダイアログボックスです。

実装コード

HTML
<button id="dialog-btn-11">Floating Card<br>Dialog</button>
                <div id="dialog-11" class="dialog">
                    <div class="dialog-content">
                        <div class="floating-header">
                            <div class="floating-icon">✨</div>
                            <span>Floating Card Dialog</span>
                        </div>
                        <div class="floating-body">
                            <p>浮遊感のあるカードデザインのダイアログボックスです。</p>
                        </div>
                        <div class="floating-footer">
                            <button class="floating-btn-secondary">Cancel</button>
                            <button class="floating-btn-primary">Confirm</button>
                        </div>
                    </div>
                </div>
CSS
#dialog-btn-11 {
    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-11:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

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

#dialog-11 .dialog-content {
    width: 80%;
    max-width: 500px;
    margin: 8% auto;
    animation: slideInFromTop-11 0.2s ease-out;
    background: #ffffff;
    border-radius: 20px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 8px 25px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.8);
    overflow: hidden;
    transform: translateY(20px);
    animation: floatIn-11 0.6s ease-out forwards;
    position: relative;
}

@keyframes floatIn-11 {
    0% {
        transform: translateY(50px) scale(0.9);
        opacity: 0;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

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

@keyframes bounce-11 {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

#dialog-11 .floating-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

#dialog-11 .floating-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer-11 3s infinite;
}

#dialog-11 .floating-icon {
    font-size: 32px;
    margin-bottom: 10px;
    display: block;
    animation: bounce-11 2s infinite;
}

#dialog-11 .floating-header span {
    font-size: 20px;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

#dialog-11 .floating-body {
    padding: 30px 20px;
    background: #ffffff;
    position: relative;
}

#dialog-11 .floating-body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20px;
    right: 20px;
    height: 1px;
    background: linear-gradient(90deg, transparent, #e0e0e0, transparent);
}

#dialog-11 .floating-body p {
    margin: 0;
    line-height: 1.7;
    color: #555;
    font-size: 16px;
    text-align: center;
}

#dialog-11 .floating-footer {
    padding: 20px;
    display: flex;
    gap: 15px;
    justify-content: center;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

#dialog-11 .floating-btn-secondary {
    background: transparent;
    color: #6c757d;
    border: 2px solid #6c757d;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

#dialog-11 .floating-btn-secondary:hover {
    background: #6c757d;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

#dialog-11 .floating-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

#dialog-11 .floating-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

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

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

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

    #dialog-11 .floating-header span {
        font-size: 16px;
    }

    #dialog-11 .floating-body p {
        font-size: 14px;
    }
}
JS
(function () {
      var btn = document.getElementById('dialog-btn-11');
      var dialog = document.getElementById('dialog-11');
      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();
        }
      });
    })();