atan()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since März 2023.
Die atan() CSS Funktion ist eine trigonometrische Funktion, die den inversen Tangens einer Zahl zwischen -∞ und +∞ zurückgibt. Die Funktion enthält eine einzelne Berechnung, die einen <angle> zwischen -90deg und 90deg zurückgibt.
Syntax
css
/* Single <number> values */
transform: rotate(atan(1));
transform: rotate(atan(4 * 50));
/* Other values */
transform: rotate(atan(pi / 2));
transform: rotate(atan(e * 3));
Parameter
Die atan(number) Funktion akzeptiert nur einen Wert als Parameter.
Rückgabewert
Der inverse Tangens einer number gibt immer einen <angle> zwischen -90deg und 90deg zurück.
- Wenn
number0⁻ist, ist das Ergebnis0⁻. - Wenn
number+∞ist, ist das Ergebnis90deg. - Wenn
number-∞ist, ist das Ergebnis-90deg.
Das bedeutet:
atan(-infinity)entspricht-90deg.atan(-1)entspricht-45deg.atan(0)entspricht0deg.atan(1)entspricht45deg.atan(infinity)entspricht90deg.
Formale Syntax
<atan()> =
atan( <calc-sum> )
<calc-sum> =
<calc-product> [ [ '+' | '-' ] <calc-product> ]*
<calc-product> =
<calc-value> [ [ '*' | / ] <calc-value> ]*
<calc-value> =
<number> |
<dimension> |
<percentage> |
<calc-keyword> |
( <calc-sum> )
<calc-keyword> =
e |
pi |
infinity |
-infinity |
NaN
Beispiele
>Elemente drehen
Die atan() Funktion kann verwendet werden, um Elemente mit rotate zu drehen, da sie einen <angle> zurückgibt.
HTML
html
<div class="box box-1"></div>
<div class="box box-2"></div>
<div class="box box-3"></div>
<div class="box box-4"></div>
<div class="box box-5"></div>
CSS
css
div.box {
width: 100px;
height: 100px;
background: linear-gradient(orange, red);
}
div.box-1 {
transform: rotate(atan(-99999));
}
div.box-2 {
transform: rotate(atan(-1));
}
div.box-3 {
transform: rotate(atan(0));
}
div.box-4 {
transform: rotate(atan(1));
}
div.box-5 {
transform: rotate(atan(99999));
}
Ergebnis
Spezifikationen
| Specification |
|---|
| CSS Values and Units Module Level 4> # trig-funcs> |