← 一覧へ

Dialog / 31 スケッチ|Sketch

デザイン見本

Sketch Dialog

手書きスケッチ風の荒削りなデザインのダイアログです。

オフホワイト背景(#fffef0)にオフセット `box-shadow: 6px 6px 0` を組み合わせ、手書きスケッチのような「ズレた線」感を表現。わずかな傾き(-0.5deg)と sketchIn-31 アニメーションで紙が置かれるような演出をします。

実装コード

HTML
<button id="dialog-btn-31">Sketch Dialog</button>
<div id="dialog-31">
    <div class="dialog-content-31">
        <div class="sketch-header">
            <span>Sketch Dialog</span>
        </div>
        <div class="sketch-body">
            <p>手書きスケッチ風の荒削りなデザインのダイアログです。</p>
        </div>
        <div class="sketch-footer">
            <button class="close-btn-31">Cancel</button>
            <button class="close-btn-31 primary">OK</button>
        </div>
    </div>
</div>
CSS
/* ボタン:オフセット影でスケッチ風 */
#dialog-btn-31 {
    background: #fffef0;
    color: #2c2c2c;
    border: 2px solid #2c2c2c;
    padding: 12px 24px;
    border-radius: 2px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 4px 4px 0 #2c2c2c;
    transition: all 0.1s;
    font-style: italic;
}
#dialog-btn-31:active {
    box-shadow: 1px 1px 0 #2c2c2c;
    transform: translate(3px, 3px);
}

/* オーバーレイ */
#dialog-31 {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0; top: 0; width: 100%; height: 100%;
    background: rgba(50, 40, 20, 0.5);
    animation: fadeIn-31 0.2s;
}
@keyframes fadeIn-31 {
    from { opacity: 0; } to { opacity: 1; }
}

/* ダイアログ本体:傾き + オフセット影 */
.dialog-content-31 {
    background: #fffef0;
    width: 80%;
    max-width: 420px;
    margin: 8% auto;
    padding: 28px 32px;
    border: 2px solid #2c2c2c;
    box-shadow: 6px 6px 0 #2c2c2c;
    animation: sketchIn-31 0.25s ease;
    transform: rotate(-0.5deg);
}
@keyframes sketchIn-31 {
    0%   { opacity: 0; transform: rotate(-2deg) scale(0.95); }
    100% { opacity: 1; transform: rotate(-0.5deg) scale(1); }
}

.sketch-header {
    border-bottom: 2px solid #2c2c2c;
    padding-bottom: 12px;
    margin-bottom: 16px;
}
.sketch-header span {
    font-size: 20px;
    font-weight: 800;
    color: #2c2c2c;
    font-style: italic;
    letter-spacing: 1px;
}
.sketch-body p {
    font-size: 14px;
    line-height: 1.7;
    color: #3a3a3a;
    margin-bottom: 20px;
    font-style: italic;
}
.sketch-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    border-top: 2px solid #2c2c2c;
    padding-top: 14px;
}

/* ボタン */
.close-btn-31 {
    background: #fffef0;
    color: #2c2c2c;
    border: 2px solid #2c2c2c;
    padding: 8px 20px;
    border-radius: 2px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 2px 2px 0 #2c2c2c;
    transition: all 0.1s;
    font-style: italic;
}
.close-btn-31:active {
    box-shadow: none;
    transform: translate(2px, 2px);
}
.close-btn-31.primary {
    background: #2c2c2c;
    color: #fffef0;
}
.close-btn-31.primary:hover { background: #1a1a1a; }

@media (max-width: 768px) {
    .dialog-content-31 { width: 90%; }
}
JS
(function () {
    var btn = document.getElementById('dialog-btn-31');
    var dialog = document.getElementById('dialog-31');
    var closeBtns = dialog.querySelectorAll('.close-btn-31');

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