Exercice 6 : Card Pokémon Responsive (Corrigé)
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Card Pokémon Responsive</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="card">
<div class="card-image">
<img src="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/25.png"
alt="Pikachu">
</div>
<div class="card-content">
<h1 class="card-title">PIKACHU</h1>
<span class="type-badge">⚡ Électrique</span>
<p class="card-description">
Ce Pokémon électrique est capable de projeter des décharges électriques
de 100 000 volts. Les forêts où vivent les Pikachu sont souvent marquées
par la foudre de leurs combats.
</p>
<h3 class="card-section-title">Statistiques</h3>
<div class="card-stats">
<div class="stat">
<div class="stat-label">PV</div>
<div class="stat-value">35</div>
</div>
<div class="stat">
<div class="stat-label">Attaque</div>
<div class="stat-value">55</div>
</div>
<div class="stat">
<div class="stat-label">Défense</div>
<div class="stat-value">40</div>
</div>
</div>
</div>
</div>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
/* MOBILE FIRST : Styles de base pour mobile (colonne) */
/* SOLUTION: Sur mobile, image au-dessus et contenu en-dessous */
.card {
background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
overflow: hidden;
max-width: 900px;
width: 100%;
display: flex;
flex-direction: column; /* Colonne sur mobile */
}
.card-image {
background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
display: flex;
justify-content: center;
align-items: center;
padding: 40px;
}
.card-image img {
width: 100%;
height: auto;
max-width: 200px;
filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.2));
}
.card-content {
padding: 30px 20px;
text-align: center;
}
.card-title {
font-size: 2rem;
color: #ffcb05;
text-shadow: 2px 2px 0 #3d7dca;
margin-bottom: 15px;
font-weight: bold;
}
.type-badge {
display: inline-block;
background: #ffd43b;
color: #333;
padding: 6px 15px;
border-radius: 20px;
font-size: 0.85rem;
font-weight: bold;
margin-bottom: 15px;
}
.card-description {
color: #333;
line-height: 1.6;
font-size: 0.95rem;
margin-bottom: 20px;
}
.card-section-title {
font-size: 1.1rem;
color: #cc0000;
margin-bottom: 10px;
font-weight: bold;
}
/* SOLUTION: Stats en Flexbox colonne sur mobile */
.card-stats {
display: flex;
flex-direction: column;
gap: 10px;
}
.stat {
background: #f0f0f0;
padding: 12px;
border-radius: 8px;
text-align: center;
}
.stat-label {
font-size: 0.75rem;
color: #666;
margin-bottom: 5px;
}
.stat-value {
font-size: 1.3rem;
font-weight: bold;
color: #3d7dca;
}
/* SOLUTION: Media Query pour Desktop avec min-width (Mobile First) */
@media (min-width: 768px) {
/* CLEF: Image à gauche, contenu à droite */
.card {
flex-direction: row;
}
/* Image prend 40% de largeur */
.card-image {
flex: 0 0 40%;
padding: 50px;
}
.card-image img {
max-width: 250px;
}
/* Contenu prend l'espace restant */
.card-content {
flex: 1;
padding: 50px;
text-align: left;
}
/* Titre plus gros sur desktop */
.card-title {
font-size: 3rem;
text-shadow: 3px 3px 0 #3d7dca;
}
/* Type badge plus gros sur desktop */
.type-badge {
padding: 8px 20px;
font-size: 0.9rem;
margin-bottom: 20px;
}
.card-description {
font-size: 1.1rem;
line-height: 1.8;
}
.card-section-title {
font-size: 1.2rem;
}
/* Stats en ligne sur desktop */
.card-stats {
flex-direction: row;
gap: 20px;
margin-top: 10px;
}
.stat {
flex: 1;
padding: 15px 25px;
}
.stat-label {
font-size: 0.8rem;
}
.stat-value {
font-size: 1.5rem;
}
}