asin()
Baseline 2023Newly available
Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
语法
css
/* 单个 <number> 值 */
transform: rotate(asin(-0.2));
transform: rotate(asin(2 * 0.125));
/* 其他值 */
transform: rotate(asin(pi / 5));
transform: rotate(asin(e / 3));
参数
返回值
number
的反正弦值总将返回介于 -90deg
和 90deg
之间的 <angle>
。
- 若
number
小于-1
或大于1
,则结果为NaN
。 - 若
number
为0⁻
,则结果为0⁻
。
形式语法
示例
旋转元素
由于 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 |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
asin() |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.