CSS3’s shape transformation allows us to stretch, scale, etc.
In this article I will mainly talk about 2D plane transformation
Attributestrans form can be transformed
transform means deformation
and it is mainly used through the function . There are the following functions
.demo { ...... transform: translate(100px, 200px); <-- }
(lowercase translatex/y is also acceptable)
.demo { ...... transform: translateX(100px) translateY(200px); /*改*/}
The result is that the element is translated to the right by 100px and down by 200px
Positive numbers rotate clockwise, negative values are allowed
.demo { ...... transform: rotate(30deg);}
However, the default rotation center of the element is the center of the element
You can modify the transformation center using our transform-origin attribute
For example, we want to rotate the element along the upper left vertex
.demo { ...... transform: rotate(30deg); transform-origin: 0 0; /*增*/}
The default form is
transform- origin: 50% 50% 0;
In addition to length and percentage, the x-axis optional values include left, center,
right y-axis optional values except length and Percentage, as well as
top, center, bottom z-axis optional value only has the length value, which we cannot use for the time being in
2D transformation
Two parameters, the width and height scaling magnification (unitless)
can also be split into scaleX() and scaleY()
.demo { ...... transform: scale(2,2);}
Note that this is the true meaning of scaling
It means that if there is text in your element, it will stretch. The effect
The equivalent form is as follows
.demo { ...... transform: scaleX(2) scaleY(3); /*改*/}
This function It will make your elements linearly distorted
Two parameters, the distortion angle of the x-axis and the y-axis, are also in the form of xxdeg
.demo { ...... transform: skew(10deg,20deg);}
.demo { ...... transform: skewX(10deg) skewY(20deg); /*改*/}
It’s really super NB
Matrix transformation is used less, it is The basics of all the above transformations
I don’t know very well
As a mathematics student, I am really ashamed T^T
The matrix transformation has 6 parameters, which can control the rotation, translation, tilt and scaling of the elements.
For example, the following code rotates the element by 30°, and translates the x and y axes by 20px each
.demo { ...... transform: matrix(0.866,0.5,-0.5,0.866,20,20);}
Maybe I will I also wrote an article on matrix on a whim...
3D TransformationRelated attributes->Portal
The above is the detailed content of About the implementation method of CSS3 element 2D plane transformation attribute transform. For more information, please follow other related articles on the PHP Chinese website!