Wyzwanie podsumowujące
Część sekcji Praktyczny frontend ścieżki HTML w Coddy. Lekcja 5 z 35.
Wyzwanie
ŁatwyTwoje zadanie:
- Ustaw globalną zmienną dla koloru tła
- Nazwa:
--main-bgi wybierz dowolny kolor. - Zastosuj ją jako
background-colordla<body>.
- Nazwa:
- Ustaw globalną zmienną dla czcionki
- Nazwa:
--main-font - Zastosuj ją jako
font-familydla<body>.
- Nazwa:
- Ustaw lokalną zmienną dla kart
- Nazwa:
--card-accent - Wartość:
tomato - Zastosuj ją do:
- Koloru
<h2>wewnątrz każdej karty - Tła
<button>wewnątrz każdej karty
- Koloru
- Nazwa:
Spróbuj swoich sił
<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>
© 2025 Healthy Recipes. All rights reserved.
</footer>
</body>
</html>
Wszystkie lekcje w sekcji Praktyczny frontend
1Zmienne
ZmienneUżywanie zmiennych CSSZmienne dla tokenów projektowychZmienne lokalneWyzwanie podsumowujące2Strategia mobile-first
Co oznacza „mobile-first”Typografia w podejściu mobile-firstNawigacja w podejściu mobile-firstObrazy w podejściu mobile-firstFormularze w podejściu mobile-firstWyzwanie podsumowujące5Komponenty interfejsu użytkownika
Menu rozwijaneKartyOdznakiPodpowiedziBanery powiadomieńWyzwanie podsumowującePoćwicz samodzielnie: Edytor online Web