J'en ai vu un divqui avait du style clear:both! À quoi sert clearin style?
<div style="clear:both">
J'en ai vu un divqui avait du style clear:both! À quoi sert clearin style?
<div style="clear:both">
Réponses:
clear:both fait tomber l'élément sous tous les éléments flottants qui le précèdent dans le document.
Vous pouvez également utiliser clear:leftou clear:rightpour le faire tomber en dessous uniquement des éléments qui ont été flottés à gauche ou à droite.
+------------+ +--------------------+
| | | |
| float:left | | without clear |
| | | |
| | +--------------------+
| | +--------------------+
| | | |
| | | with clear:right |
| | | (no effect here, |
| | | as there is no |
| | | float:right |
| | | element) |
| | | |
| | +--------------------+
| |
+------------+
+---------------------+
| |
| with clear:left |
| or clear:both |
| |
+---------------------+
Pour ajouter à la réponse de RichieHindle, consultez Floatutorial , qui vous explique comment le flottement et la compensation CSS fonctionnent.