I know how to scale from 1 to 2:
transition: all 1s ease-in-out;
transform: rotate(360deg) scale(2);
But I need from 0.1 to 1. Is there any way to do it?
scale() 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.
The default value for scale() is: scale(1) . To make an element twice as large, write 2 as the value: scale(2) . One scale() value evenly scales an element both vertically and horizontally. scale() accepts a second number value inside the parenthesis.
And, yes, we can use scale in CSS transitions and animations.
You have two options, using animation
or transition
, both will work as anticipated as long as you specify the starting values. animation
is typically the preferred option when you want more control over the intermediate keyframes, or the immediate application of an animation.
HTML
<div></div>
animation
div {
background:red;
height:100px;
width:100px;
-webkit-transform: scale(0.1);
transform: scale(0.1);
-webkit-animation: transformer 4s ease-in 0s 1;
animation: transformer 4s ease-in 0s 1;
}
@-webkit-keyframes transformer {
from {
-webkit-transform: rotate(0deg) scale(0.1);
}
to {
-webkit-transform: rotate(360deg) scale(2);
}
}
@keyframes transformer {
from {
transform: rotate(0deg) scale(0.1);
}
to {
transform: rotate(360deg) scale(2);
}
}
transition
div {
width:100px;
height:100px;
background:red;
transition: all 1s ease-in;
-webkit-transform: rotate(0deg) scale(0.1);
transform: rotate(0deg) scale(0.1);
}
div:hover {
-webkit-transform: rotate(360deg) scale(1);
transform: rotate(360deg) scale(1);
}
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