CSS rotation with respect to a reference point(CSS 相对于参考点的旋转)
问题描述
如何相对于定义的点旋转元素,即定义的 x
&y
在 CSS (webkit) 中的坐标?
How to rotate an element with respect to a defined point i.e. defined x
& y
coordinate in CSS (webkit)?
通常旋转以元素的中心点为参考.
Normally rotation make element's center point as reference.
推荐答案
你可以使用transform-origin.它定义了从元素左上角开始旋转的点.
You could use transform-origin. It defines the point to rotate around from the upper left corner of the element.
transform-origin: 0% 0%
这将围绕左上角旋转.
查看其他选项:https://developer.mozilla.org/en-US/docs/Web/CSS/transform-origin
为了安全起见,如果此链接不可用,那么这里有几个选项
for the safer side if this link not available then here are a couple of more options
transform-origin: center; // one of the keywords left, center, right, top, and bottom
transform-origin: top left; // same way can use two keywords
transform-origin: 50px 50px; // specific x-offset | y-offset
transform-origin: bottom right 60px; // third part is for 3D transform : z-offset
据我所知,没有围绕固定点旋转的选项(尽管这很方便).
As far as I know there isn't an option to rotate around a fixed point (although this would be handy).
这篇关于CSS 相对于参考点的旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:CSS 相对于参考点的旋转


基础教程推荐
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01