Skip to content

Exercices pratiques

Voici un système de design complet pour un site d’histoire :

/* ========================================
VARIABLES CSS - Système de design
======================================== */
:root {
/* Couleurs principales */
--color-primary: #FF6B6B;
--color-primary-dark: #E85555;
--color-primary-light: #FF9B9B;
--color-secondary: #4ECDC4;
--color-accent: #FFE66D;
/* Couleurs neutres */
--color-text: #2C3E50;
--color-text-light: #7F8C8D;
--color-background: #FFFFFF;
--color-background-alt: #FFF9E6;
--color-border: #E1E8ED;
/* Typographie */
--font-body: 'Nunito', sans-serif;
--font-heading: 'Fredoka', sans-serif;
--font-size-base: 18px;
--font-size-small: 16px;
--font-size-h1: 3rem;
--font-size-h2: 2.5rem;
--font-size-h3: 2rem;
/* Espacements */
--spacing-xs: 0.5rem;
--spacing-sm: 1rem;
--spacing-md: 1.5rem;
--spacing-lg: 2rem;
--spacing-xl: 3rem;
/* Effets */
--radius: 1rem;
--shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
/* ========================================
STYLES DE BASE
======================================== */
body {
font-family: var(--font-body);
font-size: var(--font-size-base);
line-height: 1.8;
color: var(--color-text);
background-color: var(--color-background);
}
/* Titres */
h1, h2, h3, h4, h5, h6 {
font-family: var(--font-heading);
line-height: 1.2;
margin-bottom: var(--spacing-md);
}
h1 {
font-size: var(--font-size-h1);
color: var(--color-primary);
}
h2 {
font-size: var(--font-size-h2);
color: var(--color-primary-dark);
}
h3 {
font-size: var(--font-size-h3);
}
/* Texte */
p {
margin-bottom: var(--spacing-md);
}
strong {
font-weight: 700;
color: var(--color-text);
}
/* ========================================
HEADER
======================================== */
.site-header {
background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
color: white;
padding: var(--spacing-lg) var(--spacing-md);
text-align: center;
}
.site-title {
font-size: var(--font-size-h1);
margin-bottom: var(--spacing-xs);
color: white;
}
.site-tagline {
font-size: var(--font-size-small);
opacity: 0.9;
}
/* ========================================
NAVIGATION
======================================== */
.main-nav ul {
list-style: none;
padding: 0;
display: flex;
gap: var(--spacing-md);
justify-content: center;
margin-top: var(--spacing-md);
}
.main-nav a {
color: white;
text-decoration: none;
font-weight: 600;
padding: var(--spacing-xs) var(--spacing-sm);
border-radius: var(--radius);
transition: background-color 0.3s;
}
.main-nav a:hover {
background-color: rgba(255, 255, 255, 0.2);
}
/* ========================================
SECTIONS
======================================== */
section {
padding: var(--spacing-xl) var(--spacing-md);
}
.intro {
background-color: var(--color-background-alt);
text-align: center;
}
/* ========================================
CARTES (Chapitres, etc.)
======================================== */
.chapter-card {
background-color: white;
border-radius: var(--radius);
box-shadow: var(--shadow);
padding: var(--spacing-lg);
margin-bottom: var(--spacing-lg);
}
.chapter-card img {
width: 100%;
height: 250px;
object-fit: cover;
border-radius: var(--radius);
margin-bottom: var(--spacing-md);
}
.chapter-meta {
font-size: var(--font-size-small);
color: var(--color-text-light);
margin-bottom: var(--spacing-sm);
}
/* ========================================
BOUTONS
======================================== */
.button {
display: inline-block;
background-color: var(--color-primary);
color: white;
padding: var(--spacing-sm) var(--spacing-lg);
border-radius: var(--radius);
text-decoration: none;
font-weight: 600;
transition: background-color 0.3s, transform 0.2s;
}
.button:hover {
background-color: var(--color-primary-dark);
transform: translateY(-2px);
}
/* ========================================
FOOTER
======================================== */
.site-footer {
background-color: var(--color-text);
color: white;
padding: var(--spacing-lg) var(--spacing-md);
text-align: center;
}
.site-footer a {
color: var(--color-accent);
}

Pendant la phase pratique, vous allez :

  • Sélectionnez 1-2 polices sur Google Fonts adaptées à votre public
  • Intégrez-les dans votre projet
  • Définissez votre échelle typographique (tailles de h1 à h6)

2. Créer votre palette de couleurs (30 min)

Section titled “2. Créer votre palette de couleurs (30 min)”
  • Utilisez Coolors ou Adobe Color
  • Choisissez 3-5 couleurs cohérentes
  • Adaptez au public cible (vif pour enfants, sobre pour ados)

3. Créer votre système de variables CSS (1h)

Section titled “3. Créer votre système de variables CSS (1h)”
  • Définissez toutes vos variables dans :root
  • Couleurs, typographie, espacements, effets
  • Organisez de manière logique et cohérente
  • Stylez toutes vos pages avec votre système
  • Header, navigation, contenu principal, footer
  • Assurez une cohérence visuelle sur tout le site

Exercice 1 : Créer un système de variables

Section titled “Exercice 1 : Créer un système de variables”

Créez un système de variables CSS complet pour un site sur le thème de l’espace (pour ados) :

Voir un exemple de solution
:root {
/* Couleurs spatiales */
--color-primary: #5D5FEF; /* Violet galactique */
--color-secondary: #00D9FF; /* Cyan néon */
--color-accent: #FF6584; /* Rose cosmique */
--color-text: #1A1A2E;
--color-background: #0F0F1E; /* Fond sombre */
--color-background-alt: #16162A;
/* Typographie moderne */
--font-body: 'Inter', sans-serif;
--font-heading: 'Space Grotesk', sans-serif;
--font-size-base: 16px;
--font-size-h1: 3rem;
--font-size-h2: 2.25rem;
--font-size-h3: 1.75rem;
/* Espacements */
--spacing-sm: 0.5rem;
--spacing-md: 1rem;
--spacing-lg: 2rem;
--spacing-xl: 3rem;
/* Effets */
--radius: 0.5rem;
--glow: 0 0 20px rgba(93, 95, 239, 0.5);
}

Créez un dégradé pour un hero de site sur la nature (pour 8-12 ans).

Voir un exemple de solution
.hero {
background: linear-gradient(
135deg,
#11998e 0%, /* Vert forêt */
#38ef7d 50%, /* Vert vif */
#85e2c6 100% /* Menthe */
);
color: white;
padding: 3rem 1.5rem;
text-align: center;
border-radius: 1rem;
}

Exercice 3 : Adapter une palette pour différents publics

Section titled “Exercice 3 : Adapter une palette pour différents publics”

Prenez cette palette de base et adaptez-la pour les 3 publics cibles :

Palette de base :

:root {
--color-primary: #3498DB;
--color-secondary: #E74C3C;
--color-text: #2C3E50;
--color-background: #FFFFFF;
}
Voir des exemples de solutions

Pour 6-8 ans :

:root {
--color-primary: #FF6B6B; /* Plus vif */
--color-secondary: #4ECDC4; /* Plus joyeux */
--color-accent: #FFE66D; /* Ajout d'une couleur accent */
--color-text: #2C3E50;
--color-background: #FFF9E6; /* Fond légèrement teinté */
}

Pour 8-12 ans :

:root {
--color-primary: #3498DB; /* Équilibré */
--color-secondary: #E74C3C;
--color-accent: #F39C12;
--color-text: #2C3E50;
--color-background: #ECF0F1; /* Fond gris clair */
}

Pour ados :

:root {
--color-primary: #5D5FEF; /* Plus sophistiqué */
--color-secondary: #FF6584;
--color-accent: #00D9FF;
--color-text: #1A1A2E; /* Plus foncé */
--color-background: #F8F9FA; /* Fond très subtil */
}

Exercice 4 : Créer une carte avec tous les styles

Section titled “Exercice 4 : Créer une carte avec tous les styles”

Créez une carte de chapitre qui utilise toutes les techniques apprises :

Voir un exemple de solution
<article class="chapter-card">
<img src="chapter-1.jpg" alt="Chapitre 1" class="chapter-image">
<div class="chapter-content">
<span class="chapter-meta">Chapitre 1 • 5 min de lecture</span>
<h2 class="chapter-title">Le début de l'aventure</h2>
<p class="chapter-excerpt">
Léo se réveilla ce matin-là avec une étrange sensation...
</p>
<a href="/chapitre-1" class="button">Lire la suite</a>
</div>
</article>
.chapter-card {
background: white;
border-radius: var(--radius);
box-shadow: var(--shadow);
overflow: hidden;
transition: transform 0.3s, box-shadow 0.3s;
}
.chapter-card:hover {
transform: translateY(-4px);
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}
.chapter-image {
width: 100%;
height: 250px;
object-fit: cover;
}
.chapter-content {
padding: var(--spacing-lg);
}
.chapter-meta {
font-size: var(--font-size-small);
color: var(--color-text-light);
text-transform: uppercase;
letter-spacing: 0.05em;
font-weight: 600;
}
.chapter-title {
color: var(--color-primary);
margin-top: var(--spacing-xs);
margin-bottom: var(--spacing-sm);
}
.chapter-excerpt {
color: var(--color-text);
margin-bottom: var(--spacing-md);
}
.button {
display: inline-block;
background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
color: white;
padding: var(--spacing-sm) var(--spacing-lg);
border-radius: calc(var(--radius) / 2);
text-decoration: none;
font-weight: 600;
transition: transform 0.2s, box-shadow 0.2s;
}
.button:hover {
transform: scale(1.05);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}