PHP前端开发

css3旋转是绕着哪根轴旋转

百变鹏仔 4周前 (09-20) #CSS
文章标签 是绕着哪根轴
css3中旋转有多种情况:1、“rotatex()”函数实现的旋转是绕x轴;2、“rotatey()”函数实现的旋转是绕y轴;3、“rotatez()”函数实现的旋转是绕z轴;4、“rotate()”函数实现的旋转是绕原点。

本教程操作环境:windows10系统、CSS3&&HTML5版、Dell G3电脑。

css3旋转是绕着哪根轴旋转

在css中,旋转可以顺时针逆时针旋转,也可以绕X、Y或Z轴旋转,不同的旋转样式对应不同的函数。

1、“rotate()”函数

立即学习“前端免费学习笔记(深入)”;

利用“rotate()”函数,可使元素顺时针或逆时针旋转。

示例如下:

<html><head><style> div{margin:30px;width:200px;height:100px;background-color:yellow;/* Rotate div */transform:rotate(9deg);-ms-transform:rotate(9deg); /* Internet Explorer */-moz-transform:rotate(9deg); /* Firefox */-webkit-transform:rotate(9deg); /* Safari 和 Chrome */-o-transform:rotate(9deg); /* Opera */}</style></head><body><div>Hello World</div></body></html>

输出结果:

2、“rotateX()”函数

利用“rotateX()”函数,可使元素绕X轴旋转。示例如下:

<html><head><style> img{transform:rotatex(180deg);}</style></head><body>@@##@@</body></html>

输出结果:

3、“rotateY()”函数

利用“rotateY()”函数,可使元素绕Y轴旋转,示例如下:

<html><head><style> img{transform:rotateY(180deg);}</style></head><body>@@##@@</body></html>

输出结果:

4、“rotateZ()”函数

利用“rotateZ()”函数,可使元素绕Z轴旋转。示例如下:

<html><head><style> img{transform:rotateZ(180deg);}</style></head><body>@@##@@</body></html>

输出结果:

(学习视频分享:css视频教程)