我需要得到一个图像旋转其变换原点在50% 50%。下面的是正确的吗?它似乎对我不起作用。
function slideUp_Menu(){
$('.main_nav').slideUp('slow', function(){
$("#arrow_up").css({ "-webkit-transform": "rotate(180deg)" });
$("#arrow_up").css( "-webkit-transform-origin", "50% 50%");
});// $('.tab_wrapper').animate({ marginTop: '193px' }, 500, 'linear');
}发布于 2012-12-14 23:00:48
我会将转换添加到css中的类中,例如:
transition: transform 1s ease;然后创建另一个类,并在其中设置转换,例如:
transform: rotate(10deg);然后我会使用jquery来添加/删除这个类,例如:
$(document).on('click', 'selector', function() {
$(this).addClass('class with transform');
});记住在你的css选择器中包含所有的浏览器前缀。
Js小提琴:http://jsfiddle.net/FhXj6/
发布于 2012-12-14 22:48:30
没有人,这是不正确的,这是为支持浏览器的webkit!
function slideUp_Menu(){
$('.main_nav').slideUp('slow', function(){
$("#arrow_up").css({ "-moz-transform": "rotate(180deg)" });
$("#arrow_up").css( "-moz-transform-origin", "50% 50%");
$("#arrow_up").css({ "-webkit-transform": "rotate(180deg)" });
$("#arrow_up").css( "-webkit-transform-origin", "50% 50%");
$("#arrow_up").css({ "transform": "rotate(180deg)" });
$("#arrow_up").css( "transform-origin", "50% 50%");
});// $('.tab_wrapper').animate({ marginTop: '193px' }, 500, 'linear');
}发布于 2012-12-14 22:55:36
你可以用jQuery来实现,但我建议你在动画中使用Greensock:
https://www.greensock.com/gsap-js/ 性能要好得多,像旋转这样的东西也是轻而易举的。在选择器的末尾使用.get(0),jQuery是一个很好的合作伙伴:)
TweenMax.to($("#arrow_up").get(0), {css:{rotation:180}});如果您想要变换原点,请查看此处:
https://www.greensock.com/get-started-js/
"transformOrigin – Sets the origin around which all transforms occur. By default, it is in the center of the element ("50% 50%")."https://stackoverflow.com/questions/13880848
复制相似问题