如何在 CSS 中为元素设置旋转点?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6652476/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 00:59:00  来源:igfitidea点击:

How can I set a rotation point for an element in CSS?

csscss-transforms

提问by kugyousha

Is it possible to set the rotation point in CSS? The default rotation point is at the 50%, 50%. I tried:

是否可以在 CSS 中设置旋转点?默认旋转点位于 50%、50%。我试过:

transform: rotate(230deg); 
rotation-point:90% 90%;

But it does not work... Any suggestions?

但它不起作用......有什么建议吗?

回答by Marco Allori

This will set the rotation pivot point on top-left corner of your element and rotate it:

这将在元素的左上角设置旋转轴心点并旋转它:

transform: rotate(-25deg);
transform-origin: 0% 0%;

take a glance at .nav_item_txtclass:

看一看.nav_item_txt班级:

http://jsfiddle.net/KHkX7/

http://jsfiddle.net/KHkX7/

回答by spraff

Use the transform-originCSS property:

使用transform-originCSS 属性:

.class {
    transform-origin: 0 0;
}

回答by Phill upNorth

Try using the transform-origin property instead, rotation-point isn't supported...

尝试改用 transform-origin 属性,不支持旋转点...

For rotating on the top right point of an element (including all targeting):

用于在元素的右上角旋转(包括所有定位):

-webkit-transform-origin: 100% 0;
-moz-transform-origin: 100% 0;
-ms-transform-origin: 100% 0;
-o-transform-origin: 100% 0;
transform-origin: 100% 0;

回答by Mayur

just go to http://www.w3schools.com/cssref/css3_pr_rotation-point.aspand read carefully. it says that none of the major browsers support this property.

只需访问http://www.w3schools.com/cssref/css3_pr_rotation-point.asp并仔细阅读。它说没有一个主要的浏览器支持这个属性。