Membuat Mocup Keyboard menggunakan HTML dan CSS [Free Download]

Membuat Mocup Keyboard menggunakan HTML dan CSS [Free Download]

Berikut adalah contoh kode HTML dan CSS untuk membuat keyboard laptop MacBook yang elegan dan professional dengan warna-warni pada keyboard

HTML (index.html)

HTML
<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Keyboard MacBook</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="keyboard">
        <div class="row">
            <div class="key red">Esc</div>
            <div class="key">F1</div>
            <div class="key">F2</div>
            <div class="key">F3</div>
            <div class="key">F4</div>
            <div class="key">F5</div>
            <div class="key">F6</div>
            <div class="key">F7</div>
            <div class="key">F8</div>
            <div class="key">F9</div>
            <div class="key">F10</div>
            <div class="key">F11</div>
            <div class="key">F12</div>
            <div class="key green">Eject</div>
        </div>
        <div class="row">
            <div class="key Teal">~</div>
            <div class="key">1</div>
            <div class="key">2</div>
            <div class="key">3</div>
            <div class="key">4</div>
            <div class="key">5</div>
            <div class="key">6</div>
            <div class="key">7</div>
            <div class="key">8</div>
            <div class="key">9</div>
            <div class="key">0</div>
            <div class="key">-</div>
            <div class="key">+</div>
            <div class="key blue">Delete</div>
        </div>
        <div class="row">
            <div class="key Olive">Tab</div>
            <div class="key">Q</div>
            <div class="key">W</div>
            <div class="key">E</div>
            <div class="key">R</div>
            <div class="key">T</div>
            <div class="key">Y</div>
            <div class="key">U</div>
            <div class="key">I</div>
            <div class="key">O</div>
            <div class="key">P</div>
            <div class="key">[</div>
            <div class="key">]</div>
            <div class="key">\</div>
        </div>
        <div class="row">
            <div class="key ForestGreen">Caps Lock</div>
            <div class="key">A</div>
            <div class="key">S</div>
            <div class="key">D</div>
            <div class="key">F</div>
            <div class="key">G</div>
            <div class="key Chocolate">H</div>
            <div class="key">J</div>
            <div class="key">K</div>
            <div class="key">L</div>
            <div class="key">;</div>
            <div class="key">'</div>
            <div class="key">Enter</div>
        </div>
        <div class="row">
            <div class="key">Shift</div>
            <div class="key">Z</div>
            <div class="key">X</div>
            <div class="key">C</div>
            <div class="key">V</div>
            <div class="key">B</div>
            <div class="key">N</div>
            <div class="key">M</div>
            <div class="key">,</div>
            <div class="key">.</div>
            <div class="key">/</div>
            <div class="key">Shift</div>
        </div>
        <div class="row">
            <div class="key Maroon">Ctrl</div>
            <div class="key">Option</div>
            <div class="key">Command</div>
            <div class="key saddlebrown">Space</div>
            <div class="key">Command</div>
            <div class="key Brown">Option</div>
            <div class="key">Left</div>
            <div class="key sienna">Down</div>
            <div class="key">Up</div>
            <div class="key">Right</div>
        </div>
    </div>
</body>
</html>
HTML

CSS (style.css)

CSS
/* style.css */
body {
    font-family: Arial, sans-serif;
    background-color: #f2f2f2;
    margin: 0;
    padding: 0;
}

.keyboard {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-top: 50px;
    margin-bottom: 50px;
}

.row {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}

.key {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 80px;
    height: 80px;
    background-color: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 5px;
    margin-right: 5px;
    font-size: 13px;
    font-weight: bold;
    color: #333333;
}

.key:hover {
            background-color: #cccccc;
        }

.key:last-child {
    margin-right: 0;
}

.key.red {
            background-color: #ff6666;
            color: #ffffff;
        }

.key.green {
            background-color: #66cc66;
            color: #ffffff;
        }

        .key.blue {
            background-color: #6666ff;
            color: #ffffff;
        }

.key.ForestGreen {
            background-color: #228B22;
            color: #ffffff;
        }

.key.Olive {
            background-color: #808000;
            color: #ffffff;
        }

.key.Teal {
            background-color: #008080;
            color: #ffffff;
        }

.key.Maroon {
            background-color: #800000;
            color: #ffffff;
        }

.key.Brown {
            background-color: #A52A2A;
            color: #ffffff;
        }

.key.sienna {
            background-color: #A0522D;
            color: #ffffff;
        }

.key.saddlebrown {
            background-color: #8B4513;
            color: #ffffff;
        }

.key.Chocolate {
            background-color: #D2691E;
            color: #ffffff;
        }
CSS

Output:

See the Pen Keyboard by WebbizID (@De-Orchids) on CodePen.

Anda dapat menyalin kode di atas ke dalam file HTML dan membukanya di browser untuk melihat hasilnya. Keyboard laptop MacBook yang elegan dan professional dengan warna-warni pada keyboard akan ditampilkan.