ダイアログボックス:ネイチャー|Dialog Box: Nature

🌿
Nature-inspired Dialog

This dialog draws inspiration from natural elements with organic shapes, earthy colors, and botanical patterns that create a calming and harmonious experience.

HTML
<div class="container">
    <button class="dialog-btn" id="dialog-btn">Nature-inspired<br>Dialog</button>
</div>

<div id="dialog" class="dialog">
    <div class="dialog-content">
        <div class="nature-header">
            <div class="nature-icon">🌿</div>
            <span>Nature-inspired Dialog</span>
        </div>
        <div class="nature-body">
            <p>This dialog draws inspiration from natural elements with organic shapes, earthy colors, and botanical patterns that create a calming and harmonious experience.</p>
        </div>
        <div class="nature-footer">
            <button class="nature-btn-secondary">Decline</button>
            <button class="nature-btn-primary">Accept</button>
        </div>
    </div>
</div>
CSS
.container {
    text-align: center;
}

.dialog-btn {
    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:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.dialog {
    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 0.3s;
}

.dialog-content {
    width: 80%;
    max-width: 500px;
    margin: 10% auto;
    background: linear-gradient(135deg, 
        rgba(34, 139, 34, 0.9), 
        rgba(85, 107, 47, 0.9), 
        rgba(154, 205, 50, 0.9));
    border: 2px solid rgba(34, 139, 34, 0.3);
    border-radius: 25px;
    padding: 30px;
    position: relative;
    box-shadow: 
        0 10px 30px rgba(34, 139, 34, 0.2),
        inset 0 0 20px rgba(154, 205, 50, 0.1);
    animation: floatIn 0.6s ease-out;
}

.nature-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(34, 139, 34, 0.3);
}

.nature-icon {
    font-size: 2em;
    animation: natureGrow 3s ease-in-out infinite;
}

.nature-header span {
    font-size: 1.5em;
    font-weight: 600;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(34, 139, 34, 0.3);
}

.nature-body {
    margin-bottom: 25px;
}

.nature-body p {
    color: #ffffff;
    line-height: 1.6;
    font-size: 1em;
    text-align: justify;
}

.nature-footer {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

.nature-btn-secondary,
.nature-btn-primary {
    padding: 12px 24px;
    border: 2px solid;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.nature-btn-secondary {
    background: transparent;
    color: #ffffff;
    border-color: #228b22;
}

.nature-btn-secondary:hover {
    background: rgba(34, 139, 34, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(34, 139, 34, 0.2);
}

.nature-btn-primary {
    background: linear-gradient(45deg, #228b22, #32cd32);
    color: white;
    border-color: #228b22;
}

.nature-btn-primary:hover {
    background: linear-gradient(45deg, #32cd32, #228b22);
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(34, 139, 34, 0.3);
}

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

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

@keyframes natureGrow {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@media (max-width: 768px) {
    .dialog-content {
        width: 90%;
        margin: 15% auto;
        padding: 15px;
    }
    
    .nature-header span {
        font-size: 16px;
    }
    
    .nature-body p {
        font-size: 14px;
    }
}
JavaScript
document.addEventListener('DOMContentLoaded', function() {
    // ダイアログボタンのイベントリスナーを設定
    const dialogBtn = document.getElementById('dialog-btn');
    const dialog = document.getElementById('dialog');
    
    dialogBtn.addEventListener('click', function() {
        dialog.style.display = 'block';
        // スクロールを無効化
        document.body.style.overflow = 'hidden';
    });
    
    // 閉じるボタンのイベントリスナーを設定
    const closeButtons = document.querySelectorAll('.nature-btn-secondary, .nature-btn-primary');
    
    closeButtons.forEach(button => {
        button.addEventListener('click', function() {
            dialog.style.display = 'none';
            // スクロールを有効化
            document.body.style.overflow = 'auto';
        });
    });
});
よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!
目次