asin()
Baseline
2023
Newly available
Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
asin()
は CSS の関数で、-1
から 1
までの数値の逆正弦を返す三角関数です。この関数には、 -90deg
から 90deg
までの <angle>
を表すラジアンの数を返す単一の計算が含まれています。
構文
css
/* 単一の <number> 値 */
transform: rotate(asin(-0.2));
transform: rotate(asin(2 * 0.125));
/* その他の値 */
transform: rotate(asin(pi / 5));
transform: rotate(asin(e / 3));
引数
asin(number)
関数は、引数として 1 つの値のみを受け入れます。
返値
number
の逆正弦で、常に <angle>
であり、 -90deg
と 90deg
の間です。
number
が-1
より小さいか1
より大きい場合、結果はNaN
になります。number
がちょうど1
の場合、結果は0
になります。
形式文法
<asin()> =
asin( <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
例
>要素の回転
asin()
関数は <angle>
を返すので、要素の回転 (rotate
) に使用することができます。
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(asin(1));
}
div.box-2 {
transform: rotate(asin(0.5));
}
div.box-3 {
transform: rotate(asin(0));
}
div.box-4 {
transform: rotate(asin(-0.5));
}
div.box-5 {
transform: rotate(asin(-1));
}
結果
仕様書
Specification |
---|
CSS Values and Units Module Level 4> # trig-funcs> |
ブラウザーの互換性
Loading…