← 一覧へ

Dialog / 21 リキッド|Liquid

デザイン見本

Liquid Dialog

液体のように縁や形がうねる有機的なダイアログです。

非対称な `border-radius` をアニメーションさせることで、液体がゆらゆらとうねっているかのような有機的な形状変化を持たせたダイアログデザインです。

実装コード

HTML
<button id="dialog-btn-21">Liquid<br>Dialog</button>
<div id="dialog-21" class="dialog">
    <div class="dialog-content-21">
        <div class="liquid-header">
            <span>Liquid Dialog</span>
        </div>
        <div class="liquid-body">
            <p>液体のように縁や形がうねる有機的なダイアログです。</p>
        </div>
        <div class="liquid-footer">
            <button class="close-btn-21">Cancel</button>
            <button class="close-btn-21 primary">OK</button>
        </div>
    </div>
</div>
CSS
#dialog-btn-21 {
    background-color: #00d2ff;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 50% 20% / 10% 40%;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.4s ease;
    min-width: 200px;
    min-height: 60px;
    display: block;
    margin: 0 auto;
    text-align: center;
    line-height: 1.4;
    vertical-align: middle;
    animation: liquidBtn 4s ease-in-out infinite alternate;
}
@keyframes liquidBtn {
    0% { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }
    100% { border-radius: 70% 30% 30% 70% / 70% 70% 30% 30%; }
}
#dialog-btn-21:hover {
    background-color: #3a7bd5;
    box-shadow: 0 10px 20px rgba(58, 123, 213, 0.4);
}

#dialog-21 {
    display: none;
    position: fixed;
    z-index: 2147483647;
    left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(10, 30, 60, 0.7);
    animation: fadeIn-21 0.3s;
}

.dialog-content-21 {
    background: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%);
    width: 80%;
    max-width: 400px;
    margin: 10% auto;
    position: relative;
    padding: 40px 30px;
    text-align: center;
    color: #fff;
    box-shadow: 0 15px 35px rgba(0,0,0,0.3);
    animation: liquidDialog 5s ease-in-out infinite alternate, slideInDrop-21 0.5s ease;
}
@keyframes liquidDialog {
    0% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; }
    100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
}

.liquid-header {
    margin-bottom: 15px;
}
.liquid-header span {
    font-size: 24px;
    font-weight: 700;
}
.liquid-body p {
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 30px;
}
.liquid-footer {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.close-btn-21 {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
}
.close-btn-21.primary {
    background: white;
    color: #3a7bd5;
}
.close-btn-21:hover {
    background: rgba(255,255,255,0.4);
    transform: translateY(-2px);
}
.close-btn-21.primary:hover {
    background: #f0f0f0;
}

@keyframes fadeIn-21 {
    from { opacity: 0; } to { opacity: 1; }
}
@keyframes slideInDrop-21 {
    0% { transform: translateY(-100px); opacity: 0; }
    80% { transform: translateY(10px); }
    100% { transform: translateY(0); opacity: 1; }
}
@media (max-width: 768px) {
    .dialog-content-21 { width: 90%; }
}
JS
(function () {
    var btn = document.getElementById('dialog-btn-21');
    var dialog = document.getElementById('dialog-21');
    var closeBtns = dialog.querySelectorAll('.close-btn-21');

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