Aller au contenu

Exercice 8 : Layout avec Sidebar 📐

🎯 Objectif

Créer un layout de page complet avec sidebar qui se réorganise selon la taille de l'écran en utilisant CSS Grid avec une approche Mobile First.

📄 Le HTML (à créer)

Créez le fichier index.html avec le contenu suivant :

🎨 Le CSS (à créer)

* {
    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;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.header {
    background: linear-gradient(135deg, #cc0000 0%, #ff4444 100%);
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.logo {
    font-size: 2.5rem;
    font-weight: 900;
    color: #ffcb05;
    text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
    letter-spacing: 3px;
    margin-bottom: 10px;
}

.header-subtitle {
    color: white;
    font-size: 1rem;
    font-weight: 600;
}

.main {
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    min-height: 400px;
}

.main h2 {
    color: #cc0000;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.main p {
    color: #666;
    line-height: 1.8;
    margin-bottom: 15px;
}

.sidebar {
    background: #ffcb05;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    min-height: 300px;
}

.sidebar h2 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.sidebar p {
    color: #333;
    line-height: 1.6;
}

.footer {
    background: #3d7dca;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.footer p {
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
}

📋 Comportement attendu

📱 Sur mobile (par défaut, < 768px)

┌─────────────────┐
│     HEADER      │
├─────────────────┤
│                 │
│      MAIN       │
│                 │
├─────────────────┤
│                 │
│     SIDEBAR     │
│                 │
├─────────────────┤
│     FOOTER      │
└─────────────────┘
  • Une seule colonne
  • Main AVANT sidebar
  • Tout en vertical

🖥️ Sur ordinateur (≥ 768px)

┌─────────────────────────────┐
│          HEADER             │
├──────────┬──────────────────┤
│          │                  │
│ SIDEBAR  │      MAIN        │
│          │                  │
├──────────┴──────────────────┤
│          FOOTER             │
└─────────────────────────────┘
  • Deux colonnes : sidebar (240px) + main (reste de l'espace)
  • Sidebar à gauche, Main à droite
  • Header et Footer sur toute la largeur

🔧 Technologies à utiliser

  • CSS Grid avec display: grid
  • Media Query avec approche Mobile First (min-width)