Menu
CoddyTech

Tantangan rangkuman

Termasuk bagian Frontend Praktis dalam perjalanan HTML di Coddy. Pelajaran 11 dari 35.

challenge icon

Tantangan

Mudah

Kamu diberi halaman HTML untuk profil pengguna. Tugasmu adalah menerapkan prinsip desain mobile-first agar halaman sepenuhnya responsif. Ikuti petunjuk berikut:

1. Navigasi Mobile-First

  • Di layar yang lebih besar, tampilkan daftar navigasi dan sembunyikan tombol menu.

2. Tipografi Mobile-First

  • Buat variabel CSS --body-font-size: 16px dan terapkan ke body. Ini akan menjadi ukuran font dasar untuk layar kecil.

3. Gambar Mobile-First

  • Gunakan tag <picture> untuk menyediakan ukuran gambar yang berbeda untuk perangkat seluler dan layar yang lebih besar.
  • Gunakan tag <source> dengan srcset yang mengarah ke gambar berukuran lebih besar, misalnya: https://upload.wikimedia.org/wikipedia/commons/1/1f/Woman_1.jpg.
  • Tambahkan media="(min-width: 768px)" agar gambar diterapkan pada layar yang lebih besar.
  • Pastikan gambar profil tetap responsif: width: 100% dan max-width: 250px membuatnya menyusut pada layar sempit. Pada layar lebar, ukurannya tetap 250px; sumber gambar yang lebih besar hanya membuatnya lebih tajam.

4. Formulir Mobile-First

  • Atur lebar semua kolom input dan tombol kirim menjadi 100%, agar memenuhi seluruh lebar dan mudah diketuk.

Halaman harus terlihat rapi, mudah dibaca, dan mudah digunakan di layar perangkat seluler maupun desktop. Atur jarak, perataan, dan ukuran responsif agar semuanya terlihat seimbang.

Coba sendiri

<!DOCTYPE html>
<html>
<head>
  <title>Mobile-First Profile</title>
  <style>
    :root {
      --primary-font: Arial, sans-serif;
      --heading-font: 'Helvetica', sans-serif;
      --h1-size: 2rem;
      --h2-size: 1.5rem;
      --primary-color: #4a90e2;
      --secondary-color: #f0f4f8;
    }

    body {
      font-family: var(--primary-font);
      margin: 0;
      padding: 20px;
      background-color: var(--secondary-color);
    }

    h1 {
      font-family: var(--heading-font);
      font-size: var(--h1-size);
      color: var(--primary-color);
      margin-bottom: 5px;
    }

    h2 {
      font-family: var(--heading-font);
      font-size: var(--h2-size);
      color: #333;
      margin-top: 0;
    }

    nav {
      margin-bottom: 20px;
    }

    .menu-button {
      display: block;
      padding: 10px 15px;
      background-color: var(--primary-color);
      color: white;
      border: none;
      border-radius: 5px;
      cursor: pointer;
      margin-bottom: 10px;
    }

    .nav-list {
      display: none;
      list-style: none;
      padding: 0;
      margin: 0;
    }

    .nav-list li {
      margin-bottom: 10px;
    }

    .nav-list li a {
      text-decoration: none;
      color: var(--primary-color);
    }

    .profile-img {
      width: 100%;
      max-width: 250px;
      border-radius: 50%;
      margin-bottom: 20px;
      display: block;
    }

    section p {
      line-height: 1.6;
      margin-bottom: 20px;
    }
    
    form {
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    input, textarea, button {
      padding: 10px;
      border: 1px solid #ccc;
      border-radius: 5px;
      font-size: 1rem;
    }

    button {
      background-color: var(--primary-color);
      color: white;
      cursor: pointer;
    }

    /* Media queries for larger screens */
    @media (min-width: 768px) {
      .nav-list {
        gap: 20px;
      }

      .nav-list li {
        margin-bottom: 0;
      }

      form {
        max-width: 500px;
      }
    }
  </style>
</head>
<body>
  <nav>
    <button class="menu-button">Menu</button>
    <ul class="nav-list">
      <li><a href="#">Home</a></li>
      <li><a href="#">About</a></li>
      <li><a href="#">Contact</a></li>
    </ul>
  </nav>

  <header>
    <h1>Jane Doe</h1>
    <h2>Web Developer & Designer</h2>
  </header>

  <section>
      <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/1f/Woman_1.jpg/250px-Woman_1.jpg" alt="Profile Image" class="profile-img">
  </section>

  <section>
    <p>Welcome to my profile! I specialize in creating mobile-first, responsive websites that look great on any device. My focus is on performance, accessibility, and clean design.</p>
  </section>

  <section>
    <form>
      <input type="text" placeholder="Your Name">
      <input type="email" placeholder="Your Email">
      <textarea placeholder="Your Message"></textarea>
      <button type="submit">Send Message</button>
    </form>
  </section>
</body>
</html>

Semua pelajaran di Frontend Praktis

Latihan sendiri: Playground Web