rotate - CSS(层叠样式表) 编辑
这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。
草案
本页尚未完工.
rotate
属性允许你单独设置transform
的旋转属性。这种映射方式可以让我们更方便的设置我们想要的效果,并且避免了简写形式需要记忆属性顺序的不方便之处。
语法
/* Keyword values */
scale: none;
/* Angle value */
rotate: 90deg;
rotate: 0.25turn;
rotate: 1.57rad;
/* x, y, or z axis name plus angle */
rotate: x 90deg;
rotate: y 0.25turn;
rotate: z 1.57rad;
/* Vector plus angle value */
rotate: 1 1 1 90deg;
值
- 角度值
- An
<angle>
specifying the angle to rotate the affected element through, around the Z axis. Equivalent to arotate()
(2D rotation) function. - x, y 或者 z 轴名称加上角度值
- The name of the axis you want to rotate the affected element around (
"x"
, "y
", or "z"
), plus an<angle>
specifying the angle to rotate the element through. Equivalent to arotateX()
/rotateY()
/rotateZ()
(3D rotation) function. - 向量加上角度值
- Three
<number>
s representing an origin-centered vector that defines a line around which you want to rotate the element, plus an<angle>
specifying the angle to rotate the element through. Equivalent to arotate3d()
(3D rotation) function. none
- 指定不应用旋转
Formal syntax
none | <angle> | [ x | y | z | <number>{3} ] && <angle>
示例
HTML
<div>
<p class="rotate">Rotation</p>
</div>
CSS
* {
box-sizing: border-box;
}
html {
font-family: sans-serif;
}
div {
width: 150px;
margin: 0 auto;
}
p {
padding: 10px 5px;
border: 3px solid black;
border-radius: 20px;
width: 150px;
font-size: 1.2rem;
text-align: center;
}
.rotate {
transition: rotate 1s;
}
div:hover .rotate {
rotate: 1 -0.5 1 180deg;
}
Result
Specifications
Specification | Status | Comment |
---|---|---|
CSS Transforms Level 2 individual transforms | Editor's Draft | Initial definition. |
初始值 | none |
---|---|
适用元素 | transformable elements |
是否是继承属性 | 否 |
计算值 | as specified |
Animation type | a transform |
Creates stacking context | yes |
浏览器兼容性
BCD tables only load in the browser
The compatibility table in 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.如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论