CSS bases
Les fondamentaux
Ouvrir le coursOnze étapes pour transformer une page HTML brute en site stylisé. À chaque étape, le résultat à obtenir, les propriétés à employer, et la correction si vous bloquez.
structure et contenu
apparence et style
site web magnifique
Les fondamentaux
Ouvrir le coursMise en page moderne
Ouvrir le coursGrilles avancées
Ouvrir le coursMulti-supports
Ouvrir le coursEffets dynamiques
Ouvrir le coursProjet Avengers
<link rel="stylesheet">
background: rgba()
linear-gradient(135deg, ...)
propriété: valeur;
rgba(..., 0.1)
css
/* Test de connexion CSS */
body {
background-color: lightgreen;
font-family: Arial, sans-serif;
}
css
/* Reset et base */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #1e3c72, #2a5298);
color: white;
line-height: 1.6;
min-height: 100vh;
}
css
/* Styles du header */
header {
background: rgba(0, 0, 0, 0.8);
padding: 20px;
text-align: center;
border-bottom: 3px solid #FFD700;
margin-bottom: 30px;
}
header h1 {
font-size: 3em;
color: #FFD700;
text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
font-weight: bold;
letter-spacing: 3px;
margin-bottom: 10px;
}
Vous avez peut-être remarqué que ce projet mélange deux unités. Ce n’est pas un hasard. Les espacements, bordures et ombres sont en pixels : padding: 20px, border-radius: 15px. Un pixel est une mesure fixe, c’est exactement ce qu’on veut pour une bordure, qui n’a aucune raison de grossir. Les tailles de texte, elles, sont presque toutes en em : font-size: 3em, font-size: 1.2em. Et c’est important. Chaque navigateur permet de choisir sa taille de texte par défaut, un réglage indispensable à qui voit mal. Une taille écrite en pixels ignore ce réglage : le texte restera petit quoi que la personne demande. Une taille en em ou en rem le respecte.
css
/* Navigation */
nav {
display: flex;
justify-content: center;
gap: 20px;
margin-top: 15px;
}
nav a {
color: white;
text-decoration: none;
padding: 10px 20px;
border-radius: 5px;
background: rgba(255, 215, 0, 0.1);
border: 1px solid rgba(255, 215, 0, 0.3);
transition: all 0.3s ease;
}
nav a:hover {
background: rgba(255, 215, 0, 0.8);
color: black;
transform: translateY(-2px);
}
css
/* Section d'accueil */
main {
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
}
#accueil {
text-align: center;
padding: 40px 30px;
background: rgba(255, 255, 255, 0.05);
border-radius: 15px;
margin-bottom: 40px;
}
#accueil h2 {
color: #FFD700;
font-size: 2.5em;
margin-bottom: 20px;
}
#accueil p {
font-size: 1.2em;
margin-bottom: 15px;
line-height: 1.8;
}
css
/* Images responsives */
img {
max-width: 100%;
height: auto;
border-radius: 10px;
border: 3px solid rgba(255, 215, 0, 0.6);
box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
transition: transform 0.3s ease;
margin: 20px 0;
}
img:hover {
transform: scale(1.05);
border-color: #FFD700;
}
/* Image d'accueil plus grande */
#accueil img {
max-width: 400px;
display: block;
margin: 30px auto;
}
css
/* 🎨 Code CSS pour les cartes héros */
/* Section des héros */
.ironman {
padding: 40px 20px;
text-align: center;
}
.ironman h3 {
color: #FFD700;
font-size: 2.2em;
margin-bottom: 30px;
}
/* Conteneur des cartes */
.ironman {
display: flex;
flex-direction: column;
gap: 30px;
}
/* Chaque carte de héros */
article {
background: rgba(255, 255, 255, 0.1);
border-radius: 15px;
padding: 25px;
border: 1px solid rgba(255, 215, 0, 0.3);
transition: transform 0.3s ease;
}
article:hover {
transform: translateY(-5px);
border-color: #FFD700;
}
/* 📐 Layout des cartes */
/* Contenu de chaque carte */
article > div {
display: flex;
align-items: center;
gap: 25px;
text-align: left;
}
article img {
width: 120px;
height: 120px;
object-fit: cover;
flex-shrink: 0;
}
article h4 {
color: #FFD700;
font-size: 1.5em;
margin-bottom: 10px;
}
css
/* 🎨 Code CSS pour les listes */
/* Listes des pouvoirs */
ul {
list-style: none;
padding: 0;
margin: 15px 0;
}
li {
background: rgba(255, 215, 0, 0.1);
margin: 8px 0;
padding: 12px 15px;
border-radius: 5px;
border-left: 4px solid #FFD700;
transition: background 0.3s ease;
}
li:hover {
background: rgba(255, 215, 0, 0.2);
}
/* 📝 Styles de texte */
/* Emphases et formatage */
strong {
color: #FFD700;
font-weight: bold;
}
em {
color: #4A90E2;
font-style: italic;
}
a {
color: #FFD700;
text-decoration: none;
border-bottom: 1px solid transparent;
transition: border-color 0.3s ease;
}
a:hover {
border-bottom-color: #FFD700;
}
css
/* 🎨 Code CSS pour le tableau */
/* Section du tableau */
#pouvoirs {
padding: 40px 20px;
text-align: center;
}
#pouvoirs h2 {
color: #FFD700;
margin-bottom: 30px;
}
/* Tableau */
table {
width: 100%;
max-width: 600px;
margin: 0 auto;
border-collapse: collapse;
background: rgba(255, 255, 255, 0.05);
border-radius: 10px;
overflow: hidden;
border: none;
}
/* 📊 En-tête et lignes */
/* En-tête du tableau */
th {
background: rgba(255, 215, 0, 0.2);
color: #FFD700;
padding: 15px;
text-align: left;
font-weight: bold;
border-bottom: 2px solid #FFD700;
}
/* Cellules */
td {
padding: 12px 15px;
border-bottom: 1px solid rgba(255, 215, 0, 0.3);
}
/* Lignes alternées */
tr:nth-child(even) {
background: rgba(255, 255, 255, 0.03);
}
css
/* 🎨 Code CSS pour le footer */
/* Footer */
footer {
background: rgba(0, 0, 0, 0.8);
border-top: 3px solid #FFD700;
margin-top: 50px;
padding: 40px 20px;
}
footer h2 {
color: #FFD700;
text-align: center;
margin-bottom: 30px;
font-size: 2em;
}
/* Colonnes du footer */
footer > div:first-of-type {
display: flex;
justify-content: space-around;
gap: 30px;
margin-bottom: 30px;
flex-wrap: wrap;
}
/* ©️ Section copyright */
footer h3 {
color: #FFD700;
font-size: 1.2em;
margin-bottom: 10px;
}
footer p {
font-size: 0.9em;
color: #ccc;
line-height: 1.5;
}
/* Copyright en bas */
footer > div:last-of-type {
text-align: center;
border-top: 1px solid rgba(255, 215, 0, 0.3);
padding-top: 20px;
margin-top: 20px;
}
css
/* ✨ Animations et effets */
/* Scroll fluide */
html {
scroll-behavior: smooth;
}
/* Transitions globales */
* {
transition: all 0.3s ease;
}
/* Animation du titre */
header h1 {
animation: glow 2s ease-in-out infinite alternate;
}
@keyframes glow {
from {
text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
}
to {
text-shadow: 2px 2px 20px rgba(255,215,0,0.8);
}
}
/* 📱 Media queries responsive */
/* Mobile */
@media (max-width: 768px) {
header h1 {
font-size: 2em;
}
nav {
flex-direction: column;
gap: 10px;
}
article > div {
flex-direction: column;
text-align: center;
}
footer > div:first-of-type {
flex-direction: column;
text-align: center;
}
}
Tony stark, génie inventeur et philanthrope
Steve rogers, le premier avenger
Dieu du tonnerre d’Asgard
Les plus puissants héros de la terre réunis
Liens rapides
Avengers tower
Couleurs avengers, typographie élégante, espacement parfait
Effets hover, transitions fluides, navigation moderne
Parfait sur mobile, tablette et ordinateur
Effets visuels dignes d’un blockbuster Marvel
Transformez vos idées en sites web extraordinaires ! commencez par les bases et progressez jusqu’aux techniques avancées.