Table of Contents
四、扭曲 skew
Home Web Front-end Front-end Q&A What does transform mean in CSS?

What does transform mean in CSS?

Sep 21, 2022 pm 05:23 PM
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.

What does transform mean in CSS?

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;
Copy after login

None means no transformation, transform-functions means one or more transformation functions, separated by spaces

What does transform mean in CSS?

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度
Copy after login

What does transform mean in CSS?

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;
Copy after login

Default value:

transform-origin: 50% 50% 0;
Copy after login

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);
Copy after login

What does transform mean in CSS?

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);
Copy after login

What does transform mean in CSS?

4. rotateY(angle): Define 3D rotation along the Y axis

transform:rotateY(45deg);
Copy after login

What does transform mean in CSS?

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);
Copy after login

What does transform mean in CSS?

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):
Copy after login

What does transform mean in CSS?

2. translate(x): Specify a Move

For example:

transform:translateX(50px):
Copy after login

What does transform mean in CSS?

##3. translate(y): Specify the Y-axis direction A move

For example:

transform:translateY(50px):
Copy after login

What does transform mean in CSS?

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);
Copy after login

What does transform mean in CSS?

可以通过transform-origin对元素的基点进行设置,同样基点在元素中心位置;例如:

transform-origin: 100% 100%;transform: scale(0.7, 0.3);
Copy after login

What does transform mean in CSS?

2、scaleX(x):在X轴方向进行缩放转换

transform: scaleX(0.7)
Copy after login

1What does transform mean in CSS?

3、scaleY(y):在Y轴方向进行缩放转换

transform: scaleY(0.7)
Copy after login

What does transform mean in CSS?

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);
Copy after login

1What does transform mean in CSS?

同样是以元素中心为基点,我们也可以通过transform-origin来改变元素的基点位置。例如

transform-origin: 100% 100%;transform: skew(10deg,10deg);
Copy after login

1What does transform mean in CSS?

2、skewX(angle):定义沿着 X 轴的 2D 倾斜转换

transform: skewX(10deg);
Copy after login

1What does transform mean in CSS?

3、skewY(angle):定义沿着 Y轴的 2D 倾斜转换

transform: skewY(10deg);
Copy after login

1What does transform mean in CSS?

注意:如果要实现3D效果,需要将transform-style属性设置为preserve-3d,即

transform-style: preserve-3d;
Copy after login

(学习视频分享: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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to insert pictures on bootstrap How to insert pictures on bootstrap Apr 07, 2025 pm 03:30 PM

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.

How to resize bootstrap How to resize bootstrap Apr 07, 2025 pm 03:18 PM

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-

How to set up the framework for bootstrap How to set up the framework for bootstrap Apr 07, 2025 pm 03:27 PM

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 bootstrap button How to use bootstrap button Apr 07, 2025 pm 03:09 PM

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

How to write split lines on bootstrap How to write split lines on bootstrap Apr 07, 2025 pm 03:12 PM

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.

How to view the date of bootstrap How to view the date of bootstrap Apr 07, 2025 pm 03:03 PM

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.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

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.

How to use bootstrap in vue How to use bootstrap in vue Apr 07, 2025 pm 11:33 PM

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.

See all articles