← 一覧へ

Dialog / 12 レトロゲーミング|Retro Gaming

デザイン見本

Retro Gaming Dialog

レトロゲーム風のノスタルジックなダイアログです。

レトロゲーム風のノスタルジックなダイアログです。

実装コード

HTML
<button id="dialog-btn-12">Retro Gaming<br>Dialog</button>
                <div id="dialog-12" class="dialog">
                    <div class="dialog-content">
                        <div class="retro-header">
                            <span>Retro Gaming Dialog</span>
                        </div>
                        <div class="retro-body">
                            <p>レトロゲーム風のノスタルジックなダイアログです。</p>
                        </div>
                        <div class="retro-footer">
                            <button class="retro-btn">Start Game</button>
                        </div>
                    </div>
                </div>
CSS
#dialog-btn-12 {
    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-12:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

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

#dialog-12 .dialog-content {
    width: 80%;
    max-width: 500px;
    margin: 8% auto;
    background: #222;
    border: 4px solid #00ff00;
    border-radius: 8px;
    box-shadow: 0 0 0 4px #111, 0 8px 0 0 #00ff00, 0 12px 24px #000;
    overflow: hidden;
    font-family: 'Press Start 2P', 'MS Gothic', 'monospace';
    color: #00ff00;
    letter-spacing: 1px;
    text-shadow: 0 0 6px #00ff00, 0 0 2px #fff;
    animation: slideInFromTop-12 0.3s ease-out;
}

#dialog-12 .retro-header {
    background: #111;
    color: #00ff00;
    padding: 15px 20px;
    text-align: center;
    border-bottom: 2px solid #00ff00;
    position: relative;
}

#dialog-12 .retro-header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 4px;
    background: repeating-linear-gradient(90deg, #00ff00 0 6px, transparent 6px 12px);
    opacity: 0.7;
}

#dialog-12 .retro-header span {
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 6px #00ff00, 0 0 2px #fff;
    border-bottom: 2px solid #00ff00;
    padding-bottom: 8px;
    position: relative;
}

#dialog-12 .retro-body {
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
}

#dialog-12 .retro-body p {
    margin: 0;
    line-height: 1.7;
    color: #00ff00;
    font-size: 12px;
    text-shadow: 0 0 4px #00ff00;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 0 0 0;
    border-top: 1px dashed #00ff00;
}

#dialog-12 .retro-footer {
    padding: 20px;
    text-align: center;
    background: #111;
    border-top: 2px solid #00ff00;
}

#dialog-12 .retro-btn {
    background: #00ff00;
    color: #000;
    border: 3px solid #00ff00;
    padding: 10px 20px;
    border-radius: 0;
    cursor: pointer;
    font-family: 'Press Start 2P', 'MS Gothic', 'monospace';
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.1s ease;
    box-shadow: 4px 4px 0 #000, inset -2px -2px 0 rgba(255, 255, 255, 0.3);
    text-shadow: none;
}

#dialog-12 .retro-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 #000, inset -2px -2px 0 rgba(255, 255, 255, 0.3);
}

#dialog-12 .retro-btn:active {
    transform: translate(0, 0);
    box-shadow: 2px 2px 0 #000, inset -2px -2px 0 rgba(255, 255, 255, 0.3);
}

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

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

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

    #dialog-12 .retro-header span {
        font-size: 14px;
    }

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