Is there any way to combine (mix) css transform properties without overriding? For example there I want to rotate and scale. http://jsfiddle.net/hyzhak/bmyN3/
<div class="item rotate-90 tiny-size"> Hello World! </div>
.rotate-90 { -webkit-transform: rotate(90deg); } .tiny-size { -webkit-transform: scale(0.25, 0.25); }
I just have a lot of elements and a lot of simple classes to transform view of the elements. And I just want to tune view of them by adding and removing some classes. Combining of all classes doesn't work because it will be hundreds of combinations.
As well I want to do it in realtime.
The number of transformations can be approximately 5 and each of them can hold about 10 states - so just describe all combinations of them with hands give you approximately
10*10*10*10*10 = 100000 cases
It is a bad solution.
Just start from there that in CSS, if you repeat 2 values or more, always last one gets applied, unless using ! important tag, but at the same time avoid using ! important as much as you can, so in your case that's the problem, so the second transform override the first one in this case...
Definition and Usage The transform property applies a 2D or 3D transformation to an element. This property allows you to rotate, scale, move, skew, etc., elements.
The transform CSS property lets you rotate, scale, skew, or translate an element.
Abstract. CSS transforms allows elements styled with CSS to be transformed in two-dimensional or three-dimensional space. This spec adds new transform functions and properties for three-dimensional transforms, and convenience functions for simple transforms.
Hmm...as far as I know, you would have to create new class and combine them this way (separated by a space):
-webkit-transform: rotate(90deg) scale(0.25, 0.25);
The way I get around this issue is to add a wrapper class around the one I want. For example, I have the wrapper which has its position set via javascript, and then the internal which is is affected by css animations - both on the transform property.
I know adding DOM nodes isn't ideal but it circumvents the script-heavy solution and lets the browser optimise the animations and transitions as it would normally.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With