js Math对象的一些方法

1.Math.PI   圆周率  3.141592657(常量,无法被赋值)

2、Math.sqrt(n)   开n平方

3.Math.ceil(Math.PI)---4     向上取整

4.Math.floor(Math.PI)---3     向下取整

5.Math.round(n)               四舍五入

6.Math.min(a,b,c) 取小
   Math.max(a,b,c)  取大

7.Math.random();随机数,范围是0-1,取不到0;可取到1;
eg:取300到 500的随机数
     Math.floor(Math.random()*201)+300)
8.正余弦函数 Math.sin(x)/Math.cos(x)

9.Math.abs()  取绝对值

拓展:
transform:rotate(n)  按照块的中心点正方向(顺时针)旋转,n为旋转角度
transform:rotate(45deg);//360deg转完一圈)
transform-origin:left/0,50%

猜你喜欢

转载自blog.csdn.net/wh13267207590/article/details/80236325