CSS atan2() 函数

定义和用法

CSS 的 atan2() 函数返回两个介于 -∞ 到 ∞ 之间的值的反正切值。

这些值可以是数字、尺寸或百分比。两个值必须是相同类型。

该函数返回一个介于 -180 到 180 度之间的角度。

实例

使用 atan2() 旋转元素:

div.a {
  transform: rotate(atan2(50, 100));
}
div.b {
  transform: rotate(atan2(30px, -3rem));
}
div.c {
  transform: rotate(atan2(40%, 75%));
}
div.d {
  transform: rotate(atan2(pi, 25));
}

亲自试一试

CSS 语法

atan2(y, x)
描述
y 必需。y 坐标。可以是数字、尺寸或百分比。
x 必需。x 坐标。可以是数字、尺寸或百分比。

技术细节

版本: CSS4

浏览器支持

表格中的数字表示首个完全支持该函数的浏览器版本。

Chrome Edge Firefox Safari Opera
111 111 108 15.4 97

相关页面

উল্লেখ:CSS acos() 函数

উল্লেখ:CSS asin() 函数

উল্লেখ:CSS atan() ফাংশন

উল্লেখ:CSS calc() 函数

উল্লেখ:CSS cos() 函数

উল্লেখ:CSS exp() 函数

উল্লেখ:CSS hypot() 函数

উল্লেখ:CSS log() 函数

উল্লেখ:CSS mod() 函数

উল্লেখ:CSS pow() 函数

উল্লেখ:CSS sin() ফাংশন

উল্লেখ:CSS sqrt() ফাংশন

উল্লেখ:CSS tan() ফাংশন