Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Transition for only one type of transform?

Is it possible to animate (using transitions) only one type of css transform?

I have css:

cell{   transform: scale(2) translate(100px, 200px);   transition: All 0.25s;   } 

Now, I want only scale to be animated. In this case I could use position:absolute and left/right properties but I far as I remember, translate() is much better in performance. I would also like to avoid using additional html elements.

Fiddle: http://jsfiddle.net/6UE28/2/

like image 980
cimak Avatar asked Jun 09 '14 12:06

cimak


People also ask

What is the difference between transform and transition in CSS?

So, what's the difference between CSS Transform and CSS Transition? The Transform property in CSS moves or modifies the appearance of an element, whereas the Transition property seamlessly and gently transitions the element from one state to another.

Can you have multiple transitions CSS?

You can transition two (or more) CSS properties by separating them with a comma in your transition or transition-property property. You can do the same with duration, timing-functions and delays as well. If the values are the same, you only need to specify one of them.

How do you transition Transformation in CSS?

Specify the Speed Curve of the Transition The transition-timing-function property can have the following values: ease - specifies a transition effect with a slow start, then fast, then end slowly (this is default) linear - specifies a transition effect with the same speed from start to end.

What is CSS individual transform property?

The transform CSS property lets you rotate, scale, skew, or translate an element. It modifies the coordinate space of the CSS visual formatting model.


1 Answers

No! you cannot use transition only for certain value of transform like scale(2).

One possible solution would be as follows: (sorry, you have to use additional html)

HTML

<div class="scale"> <div class="translate"> Hello World </div> </div> 

CSS

div.scale:hover {     transform: scale(2);     transition: transform 0.25s; } div.scale:hover div.translate {     transform: translate(100px,200px); } 
like image 190
Barun Avatar answered Sep 19 '22 16:09

Barun