search
HomeWeb Front-endHTML TutorialSummary of CSS3 Transform, Transition and Animation properties

Three properties of CSS3 related to deformation and animation ##:

Trans

form

Browser support:

Internet Explorer 10 , Firefox, Opera support the transform attribute.

Internet Explorer 9 supports the alternative -ms-transform attribute (only for 2D transformations)

Safari and

Chr

ome support. Alternative -webkit-transform property (3D and 2D transforms) Opera only supports 2D transforms

##Function

Description##translate(x,y)Define 2D transformation, move elements along the X and Y axesrotate(angle)Define 2D rotation, specify the angle in the parametersscale(x,y)Define 2D scaling transformation, change the width and height of the elementskew(x-angle,y-angle )Define 2D tilt transformation, along the X and Y axes##matrix(n,n,n,n,n,n)
  • The translate(x, y) method moves from the current element position according to the parameters given by the left (X-axis) and top (Y-axis) positions. The values ​​of x and y can be positive or negative, which respectively represent offsets in different directions.

  • rotate(angle) method represents the angle of rotation. When angle is positive, the element rotates clockwise; when it is negative, the element rotates counterclockwise.

  • scale(x, y) method indicates the scaling ratio of the element on the x-axis and y-axis. When the parameter is greater than 1, the element is enlarged; when it is less than 1, the element is reduced.

  • skew(x-angle,y-angle) method is used to distort elements. The first parameter is the horizontal distortion angle, and the second parameter is the vertical direction. Twist angle. The second parameter is an optional parameter. If the second parameter is not set, the Y axis is 0deg

  • matrix(n,n,n,n,n,n) method , specify a 2D transformation in the form of a transformation matrix containing six values. This attribute value uses the matrix

transform-origin involved in mathematics. Attribute

The transform methods we mentioned earlier are all based on the center of the element. That is, the base point of the element transformation is the center of the element by default. But sometimes we need to perform these operations on elements at different positions, then we can use transform-origin to change the base position of the element. This attribute can receive three parameters:

transform-origin: x-axis y-axis z-axis;

  • x-axis, indicating the horizontal direction. The value can be the character parameter value left, center right, or the percentage. The corresponding percentage value of the character parameter value is left=0%; center=50%; right=100%.

  • y-axis, indicating the value in the vertical direction, you can also set the character value top, center, bottom, or Take the percentage. The percentage values ​​corresponding to the character parameter values ​​are top=0%; center=50%; bottom=100%.

  • z-axis, indicating where the view is placed on the Z axis, used in 3D deformation.

3D transform transformation method

Internet Explorer 10 and Firefox support 3D transformation.
Chrome and Safari must add the prefix -webkit-.
Opera does not yet support 3D transformations (2D transformations are supported).

Three-dimensional transformations use the same properties based on two-dimensional transformations. 3D transformation in CSS3 mainly includes the following functional functions:

  • 3D displacement: 3D displacement in CSS3 mainly includes translateZ() and translate3d() Functional functions;

  • 3D rotation: 3D rotation in CSS3 mainly includes four functional functions: rotateX(), rotateY(), rotateZ() and rotate3d();

  • 3D scaling: 3D scaling in CSS3 mainly includes two functional functions: scaleZ() and scale3d();

  • 3D matrix: 3D deformation neutralization in CSS3 2D deformation also has a 3D matrix function function matrix3d().

There are also the following transformation attributes:

    • transform-style: Specifies how nested elements are displayed in 3D space .

    • perspective: Specifies the perspective effect of 3D elements.

    • perspective-origin: Specifies the bottom position of the 3D element.

    • backface-visibility: Defines whether the element is visible when not facing the screen.

Currently, the compatibility of the transform 3d attribute in major mainstream browsers is not particularly good. Interested readers can learn more about it on their own. Below we introduce several commonly used functional methods:

rotateX() method, rotate the element around the X axis at a given degree;
rotateY() method, rotate it around the Y axis at a given degree Axis-rotated element;
rotateZ() method, rotates an element around its Z-axis at a given degree.

Transition

W3CThe transition of css3 is described in the standard like this: "The transition of css allows css The attribute value transitions smoothly within a certain time interval. This effect can be triggered by mouse click, focus, click, or any change to the element, and smoothly changes the CSS attribute value with animation effect.”## The value of the

#transition attribute includes the following four:

    • transition-property: Specifies which css attribute of the

      HTML element is used for transition gradient processing , this attribute can be various standard css attributes such as color, width, height, etc.

    • transition-duration: Specifies the duration of attribute transition

    • transition-timing-function: Specify the speed of the gradient:
      1. ease: (gradually slows down) default value, the ease function is equivalent to the Bezier curve (0.25, 0.1, 0.25, 1.0);
      2. linear: (uniform speed), the linear function is equivalent to the Bezier curve (0.0, 0.0, 1.0, 1.0);
      3. ease-in: (acceleration), the ease-in function is equivalent to To the Bezier curve (0.42, 0, 1.0, 1.0);
      4. ease-out: (deceleration), the ease-out function is equivalent to the Bezier curve (0, 0, 0.58, 1.0);
      # 5. ease-in-out: (accelerate and then decelerate), the ease-in-out function is equivalent to the Bezier curve (0.42, 0, 0.58, 1.0);
      6. cubic-bezier: (this value allows You can customize a time curve), a specific cubic-bezier curve. The four values ​​(x1, y1, x2, y2) are specific to points P1 and P2 on the curve. All values ​​must be within the [0, 1] range, otherwise they will be invalid.

    • transition-delay: Specify the delay time, that is, how long it takes to start the transition process.

Browser Compatibility

Internet Explorer 9 and earlier version, the transition attribute is not supported.

Internet Explorer 10, Firefox, Opera and Chrome support the transition attribute. Chrome 25 and earlier and Safari require the prefix -webkit-.

Animation

To use animation animation, you must first familiarize yourself with keyframes and the grammatical rules of Keyframes: naming is It starts with "@keyframes", followed by the "name of the animation" plus a pair of curly brackets "{}". In the brackets are some style rules for different time periods. Different keyframes are expressed by from (equivalent to 0%), to (equivalent to 100%) or percentage (in order to get the best browser support, it is recommended to use percentage),

@keyframes is defined. To make it work, it must be bound to a selector through animation, otherwise the animation will have no effect. The attributes of animation are listed below:

Define the 2D transformation using a matrix of six values
##animation-iteration-Specifies the number of times the animation is playedThe default is 1 (infinite: unlimited timesanimation- Specifies whether the animation will be played in reverse in the next cycle The default is "normal" (reverse: play in reverse; alternate: play forward in odd numbers, play in reverse in even numbers; alternate -reverse: Play in the reverse direction for odd times, and play forward for even times)##animation-play-stateThe default is "running" (paused: paused animation)
Attribute Description Value
animation Abbreviated attribute for all animation attributes, except animation-play-state attribute
animation-name Specifies the name of @keyframes animation
animation-duration Specifies the seconds or milliseconds it takes for the animation to complete a cycle The default is 0
animation-timing-function Specifies the speed curve of the animation The default is "ease"
animation-delay Specifies when the animation starts The default is 0
count
direction
Specifies whether the animation is running or paused

##Browse Server compatibility

##Internet Explorer 10, Firefox and Opera support @keyframes rules and animation attributes Chrome and Safari require the prefix -webkit-

Note: Internet Explorer 9, and earlier versions, do not support @keyframe rules or animation attributes

The above content comes from: http://blog.csdn.net/u014607184/article/details. /51801393

The above is the detailed content of Summary of CSS3 Transform, Transition and Animation properties. For more information, please follow other related articles on the PHP Chinese website!

Statement
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
How to implement multi-project carousel in Bootstrap 4?How to implement multi-project carousel in Bootstrap 4?Apr 30, 2025 pm 03:24 PM

Solution to implement multi-project carousel in Bootstrap4 Implementing multi-project carousel in Bootstrap4 is not an easy task. Although Bootstrap...

How does deepseek official website achieve the effect of penetrating mouse scroll event?How does deepseek official website achieve the effect of penetrating mouse scroll event?Apr 30, 2025 pm 03:21 PM

How to achieve the effect of mouse scrolling event penetration? When we browse the web, we often encounter some special interaction designs. For example, on deepseek official website, �...

How to modify the playback control style of HTML videoHow to modify the playback control style of HTML videoApr 30, 2025 pm 03:18 PM

The default playback control style of HTML video cannot be modified directly through CSS. 1. Create custom controls using JavaScript. 2. Beautify these controls through CSS. 3. Consider compatibility, user experience and performance, using libraries such as Video.js or Plyr can simplify the process.

What problems will be caused by using native select on your phone?What problems will be caused by using native select on your phone?Apr 30, 2025 pm 03:15 PM

Potential problems with using native select on mobile phones When developing mobile applications, we often encounter the need for selecting boxes. Normally, developers...

What are the disadvantages of using native select on your phone?What are the disadvantages of using native select on your phone?Apr 30, 2025 pm 03:12 PM

What are the disadvantages of using native select on your phone? When developing applications on mobile devices, it is very important to choose the right UI components. Many developers...

How to optimize collision handling of third-person roaming in a room using Three.js and Octree?How to optimize collision handling of third-person roaming in a room using Three.js and Octree?Apr 30, 2025 pm 03:09 PM

Use Three.js and Octree to optimize collision handling of third-person roaming in the room. Use Octree in Three.js to implement third-person roaming in the room and add collisions...

What problems will you encounter when using native select on your phone?What problems will you encounter when using native select on your phone?Apr 30, 2025 pm 03:06 PM

Issues with native select on mobile phones When developing applications on mobile devices, we often encounter scenarios where users need to make choices. Although native sel...

Why can some websites achieve mouse scrolling and penetration effect, while others cannot?Why can some websites achieve mouse scrolling and penetration effect, while others cannot?Apr 30, 2025 pm 03:03 PM

Exploring the implementation principle of mouse scrolling events When browsing some websites, you may notice that some page elements still allow scrolling the entire page when the mouse is hovering...

See all articles

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software