Desafío de repaso
Parte de la sección Practical Frontend del Journey de HTML de Coddy — lección 5 de 35.
Desafío
FácilTu tarea:
- Establece una variable global para el color de fondo
- Nombre:
--main-bgy elige cualquier color que te guste. - Aplícalo como el
background-colorpara el<body>.
- Nombre:
- Establece una variable global para la fuente
- Nombre:
--main-font - Aplícala como el
font-familypara el<body>.
- Nombre:
- Establece una variable local para las tarjetas
- Nombre:
--card-accent - Valor:
tomato - Aplícalo a:
- El color del
<h2>dentro de cada tarjeta - El fondo del
<button>dentro de cada tarjeta
- El color del
- Nombre:
Pruébalo tú mismo
<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>
Todas las lecciones de Practical Frontend
1Variables
VariablesUso de variables CSSVariables para Design TokensVariables localesDesafío de repaso