What does transform mean in CSS?
In CSS, transform means change and deformation. It is mainly used to set the shape change of elements and realize 2D or 3D conversion of elements; this attribute can be used in conjunction with attribute values (conversion functions) to transform elements. Rotate rotate, distort skew, scale, move translate and matrix deformation matrix.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
Transform literally means transformation, which means change. It is a new attribute of CSS3, which is used to set the shape change of elements and realize 2D or 3D transformation of elements.
Transform in CSS3 mainly includes the following types: rotation rotate, distortion skew, scaling scale and mobile translate and matrix transformation matrix.
Grammar:
transform: none|transform-functions;即:transform: rotate | scale | skew | translate |matrix;
None means no transformation, transform-functions means one or more transformation functions, separated by spaces
1. Rotate rotate
1. rotate(angle): Rotate the original element through the specified angle parameter Specify a 2D rotation.
angle refers to the rotation angle (unit is deg). If the set value is a positive number, it means clockwise rotation. If the set value is a negative number, it means counterclockwise rotation.
transform: rotate(45deg); //顺时针旋转30度
Note: When rotating, the center point of the element is used as the base point by default. You can define the base point position of the rotation through the transform-origin attribute
transform-origin attribute: Defines the base point of rotation.
Syntax:
transform-origin: x-axis y-axis z-axis;
Default value:
transform-origin: 50% 50% 0;
In the case of 2D, the upper left corner of the default element is 0% 0%, for example: rotate 45 degrees around the lower right corner
transform-origin: 100% 100%;transform: rotate(45deg);
2, rotate3d(x, y, z, angle ): Define 3D rotation
Not commonly used
3. rotateX(angle): Define 3D rotation along the X axis
transform: rotateX(45deg);
4. rotateY(angle): Define 3D rotation along the Y axis
transform:rotateY(45deg);
5. rotateZ(angle): Define 3D rotation along the Z axis
As can be seen from the following example, the direction of the Z axis is perpendicular to The direction of the window
transform:rotateZ(45deg);
2. Move translate
1. translate(x, y): Define 2D mobile transformation
x is the first transition value parameter, and y is the second transition value parameter option. If not provided, ty has 0 as its value. That is, translate(x,y), which means that the object is translated according to the set x, y parameter values. When the value is a negative number, the object is moved in the opposite direction. Its base point defaults to the center point of the element, or it can also be based on transform-origin. Make a base point change.
For example:
transform:translate(50px,50px):
2. translate(x): Specify a Move
For example:
transform:translateX(50px):
##3. translate(y): Specify the Y-axis direction A move
For example:transform:translateY(50px):
4、translate3d(x, y, z):定义3D移动转换
5、translateZ(z):指定Z轴方向上的一个移动
三、缩放 scale
1、scale(x, y):定义2D缩放转换。
X表示水平方向缩放的倍数,Y表示垂直方向的缩放倍数,而Y是一个可选参数,如果没有设置Y值,则表示X,Y两个方向的缩放倍数是一样的。并以X为准。例如:
transform: scale(0.7, 0.3);
可以通过transform-origin对元素的基点进行设置,同样基点在元素中心位置;例如:
transform-origin: 100% 100%;transform: scale(0.7, 0.3);
2、scaleX(x):在X轴方向进行缩放转换
transform: scaleX(0.7)
3、scaleY(y):在Y轴方向进行缩放转换
transform: scaleY(0.7)
4、scale3d:(x, y, z):定义3D缩放转换
5、scaleZ(z):在Z轴方向进行缩放转换
四、扭曲 skew
1、skew(x-angle, y-angle) :定义沿着 X 和 Y 轴的 2D 倾斜转换。
skew是用来对元素进行扭曲变行,第一个参数是水平方向扭曲角度,第二个参数是垂直方向扭曲角度。其中第二个参数是可选参数,如果没有设置第二个参数,那么Y轴为0deg。:
transform: skew(10deg,10deg);
同样是以元素中心为基点,我们也可以通过transform-origin来改变元素的基点位置。例如
transform-origin: 100% 100%;transform: skew(10deg,10deg);
2、skewX(angle):定义沿着 X 轴的 2D 倾斜转换
transform: skewX(10deg);
3、skewY(angle):定义沿着 Y轴的 2D 倾斜转换
transform: skewY(10deg);
注意:如果要实现3D效果,需要将transform-style属性设置为preserve-3d,即
transform-style: preserve-3d;
(学习视频分享:web前端)
The above is the detailed content of What does transform mean in CSS?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.

To adjust the size of elements in Bootstrap, you can use the dimension class, which includes: adjusting width: .col-, .w-, .mw-adjust height: .h-, .min-h-, .max-h-

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.

Answer: You can use the date picker component of Bootstrap to view dates in the page. Steps: Introduce the Bootstrap framework. Create a date selector input box in HTML. Bootstrap will automatically add styles to the selector. Use JavaScript to get the selected date.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.
