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 Arkustangens einer Zahl zwischen -∞ und +∞ zurückgibt. Die Funktion enthält eine einzelne Berechnung, die die Anzahl der Bogenmaßgrade als ein <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 ihren Parameter.
Rückgabewert
Der Arkustangens einer number wird immer ein <angle> zwischen -90deg und 90deg zurückgeben.
- 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-45degatan(0)entspricht0degatan(1)entspricht45degatan(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 rotieren
Die atan() Funktion kann verwendet werden, um Elemente zu rotieren, da sie ein <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> |
Browser-Kompatibilität
Loading…