Fonction CSS calc()
Exemple
Utilisez calc() pour calculer la largeur d'un élément <div> :
#div1 {
position: absolute;
left: 50px;
width: calc(100% - 100px);
border: 1px solid black;
background-color: yellow;
padding: 5px;
text-align: center;
}
Définition et utilisation
La fonction calc() effectue un calcul à utiliser comme valeur de propriété.
Version: | CSS3 |
---|
Prise en charge du navigateur
Les chiffres du tableau indiquent la première version du navigateur qui prend entièrement en charge la fonction.
Les nombres suivis de -webkit-, -moz- ou -o- spécifient la première version qui a fonctionné avec un préfixe.
Function | |||||
---|---|---|---|---|---|
calc() | 26.0 19.0 -webkit- |
9.0 | 16.0 4.0 -moz- |
7.0 6.0 -webkit- |
15.0 |
Syntaxe CSS
calc(expression)
Value | Description |
---|---|
expression | Required. A mathematical expression. The result will be used as the value. The following operators can be used: + - * / |