Menu
Coddy logo textTech

복습 챌린지

Coddy HTML 여정의 Practical Frontend 섹션에 포함된 레슨 — 35개 중 5번째.

challenge icon

챌린지

쉬움

수행할 작업:

  1. 배경색을 위한 전역 변수 설정
    • 이름: --main-bg로 설정하고 원하는 색상을 선택하세요.
    • 이 변수를 <body>background-color로 적용하세요.
  2. 글꼴을 위한 전역 변수 설정
    • 이름: --main-font
    • 이 변수를 <body>font-family로 적용하세요.
  3. 카드를 위한 지역 변수 설정
    • 이름: --card-accent
    • 값: tomato
    • 다음에 적용하세요:
      • 각 카드 내부의 <h2> 색상
      • 각 카드 내부의 <button> 배경색

직접 해보기

<html>
<head>
  <title>CSS Variables Recap Challenge</title>
  <style>
    /* Global Variables */
    :root {    
        --primary-color: seagreen;
    }

    body {
      margin: 0;
      padding: 0;
    }

    header {
      background-color: var(--primary-color);
      color: white;
      padding: 20px;
      text-align: center;
    }

    header h1 {
      margin: 0;
      font-size: 2rem;
    }

    header p {
      margin: 5px 0 0;
      font-size: 1rem;
      opacity: 0.9;
    }

    main {
      padding: 20px;
      display: grid;
      gap: 20px;
      grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
    .hero {
        background: url('https://upload.wikimedia.org/wikipedia/commons/c/c0/Healthy_Food_-_Colourful_Fruit_and_Veg_-_50191699151.jpg') center/cover no-repeat;
        color: white;
        text-align: center;
        padding: 30px 20px 50px 20px;
        border-radius: 10px;
        margin: 10px;
        }

    .hero button {
        background-color: var(--primary-color);
        padding: 10px 20px;
        border: none;
        border-radius: 5px;
        font-weight: bold;
        cursor: pointer;
        color: white;
    }

    .card {
      background: white;
      border-radius: 10px;
      padding: 15px;
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
      display: flex;
      flex-direction: column;
      justify-content: space-between;
    }

    .card h2 {
      margin: 0 0 10px;
    }

    .card p {
      font-size: 0.9rem;
      color: #333;
    }

    .card button {
      margin-top: 10px;
      border: none;
      padding: 8px 12px;
      color: black;
      border-radius: 5px;
      font-weight: bold;
      cursor: pointer;
    }

    footer {
      background-color: #eee;
      text-align: center;
      padding: 15px;
      font-size: 0.85rem;
      margin-top: 20px;
    }
  </style>
</head>
<body>

  <header>
    <h1>Healthy Recipes</h1>
    <p>Fresh, tasty, and colorful meals you can make at home</p>
  </header>
<section class="hero">
  <div class="hero-content">
    <h2>Eat Healthy, Live Happy</h2>
    <button>Explore Recipes</button>
  </div>
</section>
  <main>
    <div class="card">
      <h2>Avocado Salad</h2>
      <p>A healthy salad with fresh avocado, tomatoes, and herbs.</p>
      <button>Read Recipe</button>
    </div>

    <div class="card special">
      <h2>Berry Smoothie</h2>
      <p>Refreshing smoothie with blueberries, strawberries, and yogurt.</p>
      <button>Read Recipe</button>
    </div>

    <div class="card">
      <h2>Quinoa Bowl</h2>
      <p>Nutritious quinoa with roasted vegetables and chickpeas.</p>
      <button>Read Recipe</button>
    </div>
  </main>

  <footer>
    &copy; 2025 Healthy Recipes. All rights reserved.
  </footer>

</body>
</html>

Practical Frontend의 모든 레슨