Position : static (défaut)
Position : relative
Position : absolute (par rapport à ce conteneur)
Position : sticky (reste collé en haut)
Position : fixed (toujours en bas à droite)
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Exemples de position CSS</title>
<style>
.static {
position: static;
background-color: lightblue;
padding: 10px;
}
.relative {
position: relative;
top: 20px;
left: 10px;
background-color: lightgreen;
padding: 10px;
}
.absolute {
position: absolute;
top: 50px;
right: 20px;
background-color: lightcoral;
padding: 10px;
}
.fixed {
position: fixed;
bottom: 0;
right: 0;
background-color: lightyellow;
padding: 10px;
}
.sticky {
position: sticky;
top: 0;
background-color: lightgray;
padding: 10px;
}
.container {
position: relative;
height: 300px;
border: 1px solid black;
}
</style>
</head>
<body>
<div class="static">Position : static (défaut)</div>
<div class="relative">Position : relative</div>
<div class="container">
<div class="absolute">Position : absolute (par rapport à ce conteneur)</div>
</div>
<div class="sticky">Position : sticky (reste collé en haut)</div>
<div style="height: auto;"></div> <!-- Pour permettre de scroller -->
<div class="fixed">Position : fixed (toujours en bas à droite)</div>
<div style="display:Bloc;">
</body>
</html>