简体   繁体   English

如何使用 -moz-transform 永久更改 css 元素?

[英]how to make changes permanently to css elements with -moz-transform?

        var transform = ['scale(' + scale + ')'];
        $.merge(transform, ['rotate(' + rotate + 'deg)']);
        $(this).css(-moz-transform, transform.join(' '));

this block of code executes when an event is generated, the new scaling and rotation is added to css element,but whenever the same event is generated again the css element resets itself to the original size and position.The transformation is carried out after resetting during the second time.I want to eliminate the resetting of the element to original size and position.How can i make the change permanent in the first time when event is fired,and build on it when the event is fired the second time?此代码块在生成事件时执行,新的缩放和旋转添加到 css 元素,但每当再次生成相同的事件时,css 元素将自身重置为原始大小,并且在重置 D 期间执行 Z4757FE07FD492A8BE0EA6A760D683 期间的转换。第二次。我想消除将元素重置为原始大小和 position。如何在第一次触发事件时使更改永久化,并在第二次触发事件时建立它? Please help thanks in advance请帮助提前谢谢

There's nothing wrong with this code, but keep in mind you're setting scale and rotate in absolute terms, not relative to its 'initial' state.这段代码没有任何问题,但请记住,您设置scalerotate是绝对值,而不是相对于它的“初始”state。

So each time this code executes, the -moz-transform property of your element is being overwritten.因此,每次执行此代码时,元素的-moz-transform属性都会被覆盖。 If you want to rotate and scale it based on it's current state, you'll have to keep track of your scale and rotate values and adjust them as necessary.如果您想根据当前的 state 对其进行旋转和缩放,则必须跟踪您的scalerotate值并根据需要进行调整。 eg, if this code is in a loop, you can do rotate=rotate+5;例如,如果此代码在循环中,则可以执行rotate=rotate+5; or something like that.或类似的东西。

You can also request these properties from the CSS using ($this).css('-moz-transform') , parse that to get the values you want, and update scale and rotate accordingly.您还可以使用($this).css('-moz-transform')从 CSS 请求这些属性,对其进行解析以获取所需的值,并相应地更新scalerotate

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM