Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When you scale an element with css3, what transition-properties are being changed?

Which css transition property is actually used when you use the css property:

.selector {
  transform: scale(n);
}

I'm trying to isolate which values are actually changing when I scale something with CSS. This works, but it is also animating everything, which I don't want to do. I only want to animate the height/width of the object:

.selector {
  transition: all 0.3s linear;
}

Instead of 'all', I have tried settings 'width height', but it doesn't smoothly animate anymore. It just snaps to the final position.

like image 299
tvpmb Avatar asked Jul 25 '13 18:07

tvpmb


People also ask

How do you scale property in CSS3?

The scale() CSS function defines a transformation that resizes an element on the 2D plane. Because the amount of scaling is defined by a vector, it can resize the horizontal and vertical dimensions at different scales. Its result is a <transform-function> data type.

Which CSS property is used for transition effect?

The transition-property CSS property sets the CSS properties to which a transition effect should be applied.

What are CSS3 transitions and transform?

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.


1 Answers

You can use transform

transition: transform 200ms linear;

You need the vendor prefixes in that too like this

-webkit-transition: -webkit-transform 200ms linear;

I didn't fully understand your question but I'm guessing you just want to animate the scale and nothing else on that element, if so then this is what you need.

like image 139
iConnor Avatar answered Nov 15 '22 21:11

iConnor