Propriété de style maxHeight
Exemple
Définissez la hauteur maximale d'un élément <div> :
document.getElementById("myDIV").style.maxHeight = "15px";
Définition et utilisation
La propriété maxHeight définit ou renvoie la hauteur maximale d'un élément.
La propriété maxHeight n'a d'effet que sur les éléments de niveau bloc ou sur les éléments avec une position absolue ou fixe.
Remarque : La hauteur d'un élément ne peut jamais être supérieure à la valeur spécifiée par la propriété maxHeight.
Conseil : Pour définir ou renvoyer la hauteur minimale d'un élément, utilisez la propriété minHeight .
Prise en charge du navigateur
Property | |||||
---|---|---|---|---|---|
maxHeight | Yes | Yes | Yes | Yes | Yes |
Syntaxe
Renvoyez la propriété maxHeight :
object.style.maxHeight
Définissez la propriété maxHeight :
object.style.maxHeight = "none|length|%|initial|inherit"
Valeurs de propriété
Value | Description |
---|---|
none | No limit on the height of the element. This is default |
length | Defines the maximum height in length units |
% | Defines the maximum height in % of the parent element |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Détails techniques
Valeur par défaut: | rien |
---|---|
Valeur de retour : | Une chaîne, représentant la hauteur maximale d'un élément |
Version CSS | CSS2 |
Plus d'exemples
Exemple
Renvoie la hauteur maximale d'un élément <div> :
alert(document.getElementById("myDIV").style.maxHeight);
Pages connexes
Tutoriel CSS : Dimension CSS
Référence CSS : propriété max-height
❮ Objet de style