开发者

-webkit-transform translate around center

开发者 https://www.devze.com 2023-03-15 09:28 出处:网络
For fun Im making a analog clock :D but how to i get it to rotate around center? I want to rotate the thingy showing minutes. its already placed pointing at 15 like in 15.15, 16.15.

For fun Im making a analog clock :D but how to i get it to rotate around center? I want to rotate the thingy showing minutes. its already placed pointing at 15 like in 15.15, 16.15.

doing a plain rotate开发者_JAVA百科("10deg") wil rotate it around it self. guessing i have to do something like this:

$("#minPointer").css("-webkit-transform", "translate(-100px, -100px)");
$("#minPointer").css("-webkit-transform", "rotate("+val+"deg)" );
$("#minPointer").css("-webkit-transform", "translate(100px, 100px)" );

the pin is placed center in a 200x200 box. and the above does not work :(


Use -webkit-transform-origin to set what point transformations occur with respect to:

// Replace percentages to reflect what point you want to rotate around.
// Pixel values are fine.
$("#minPointer").css("-webkit-transform-origin", "50% 100%" );
$("#minPointer").css("-webkit-transform", "rotate("+val+"deg)" );


You need to use the transform-origin property.

Information and examples: https://developer.mozilla.org/En/CSS/-moz-transform-origin

0

精彩评论

暂无评论...
验证码 换一张
取 消