search
HomeWeb Front-endCSS Tutorialcss3 transition and 2d transformation

1.transition
Syntax: transition: property duration timing-function delay;
Transition-property Set the css property name of the transition effect
Syntax: transition-property: none | all | property
None No properties will get transition effects
All properties will get transition effects.
     property defines a list of CSS property names for applying transition effects. The list is separated by commas.
                                                                ]over how many seconds or milliseconds it takes to complete the transition effect
     Syntax: transition-duration: time; The default value is 0, which means there will be no effect.
Transition-timing-function specifies the speed curve of the speed effect.
Syntax: transition-timing-function: linear|ease|ease-in|ease-out|ease-in-out|cubic-bezier(n,n,n,n);
Linear specifies the same speed A transitional effect from start to finish.
       ease stipulates to start at a slow speed, then go fast, and then end at a slow speed.
      ease-in specifies an excessive effect that starts at a slow speed.
      ease-out specifies an excessive effect that ends at a slow speed.
      ease-in-out specifies a transition effect that starts and ends at a slow speed.
     cubic-bezier(n,n,n,n) Define your own value in cubic-bezier. Possible values ​​are values ​​between 0 and 1.
    transition-delay Defines when the transition effect starts
    Syntax: transititon-delay: time;
  time specifies the time to wait before the transition effect starts.

Example:

;width:300px;height:150px;}

  
  

## Example: (Bezier curve)
1.295,0.000,1.610);}
    .box:hover{width:500px;}
   

   

Result: As shown in the figurecss3 过渡和2d变换

      



                                     uting Me >> .box{width:100px;height:100px;background :red; transition:1swidth,2s height,3s background;}
   .box:hover{width:300px;height:150px;background:blue;}
   
   


Result: As shown in the figure

css3 过渡和2d变换

##2.transform

The letters are transformed. The meaning of change, in CSS3, transform mainly includes the following types, rotation rotate, skew, scale and translate, as well as matrix transformation matrix
Syntax: transform: none | [      That is: transform: rotate | scale | skew | translate |matrix;

None means how to transform without entering; means one or more transformation functions, with spaces Separate;

There are three types of rotate, scale, and translate, but I need to remind everyone here that in the past, our overlay effects were separated by commas (","),

      But when using multiple attributes in transform, they need to be separated by spaces. Remember, they are separated by spaces.

     rotate
                                                       over forward in word to specify a 2D rotation (2D rotation) on the original element through the specified angle parameter, you need to first define the transform-origin attribute.
                                                              ccogene Over in in >>, where angle refers to the angle of rotation
        If the set value is a positive number, it means clockwise rotation, if the set value is a negative number, it means counterclockwise rotation.
                                                                   Move at the same time); translateX(x) only moves in the horizontal direction (X-axis movement) translateY(Y) only moves in the vertical direction (Y-axis movement)

       Scale

                                                                 duct[Y] could only move in the vertical direction (Y-axis movement]_ There are also three situations: scale(x,y) causes the element to scale horizontally and vertically at the same time (that is, the X-axis and Y-axis scale simultaneously); scaleX(x) the element only scales horizontally (X-axis scaling);

The scaleY(y) element only scales in the vertical direction (Y-axis scaling), but they have the same scaling center point and base,
Its center point is the center position of the element, and the scaling base is 1. If its value is greater than 1 element If the value is less than 1, the element will shrink. At the same time, it is distorted according to a certain angle value); skewX(x) only distorts the element in the horizontal direction (X-axis distortion);

         skewY(y) only makes the element distorted in the vertical direction (Y Axis twist deformation)

Matrix matrix
Specifying a 2D transformation in the form of a six-valued (a, b, c, d, e, f) transformation matrix is ​​equivalent to directly applying a [a b c d e f] transformation matrix, which is based on the horizontal direction (X axis). Reposition the element in the vertical direction (Y-axis) and change the base point of the element transform-origin. Its main function is to allow us to change the base point position of the element before performing the transform action,

Because the default base point of our element is Its center position, in other words, when we do not use transform-origin to change the base point position of the element, operations such as rotate, translate, scale, skew, and matrix performed by transform are all based on the center position of the element.

Example: (rotation)

.box:hover { -webkit-transform:rotate(45deg);}

## transition:2s;}
                                .box:hover{-webkit-transform:translate(-100px,200px);}
                                                                            /p>
   Result: The position of the element changes.

      Example: (zoom) box: hover{webkit-transform:scale(2);}
# }
        .box:hover{-webkit-transform:skewX(45deg);}
     
     

111


: As shown in the figure

Example: (matrix)css3 过渡和2d变换 100px auto 0; transition:2s;}

                            

111


    Result: as shown

     

        demo 示例:
          
          


               


                   

               


               


               


               


          
          <script><br/>                  var oList=document.getElementById("list");<br/>                  var oCss=document.getElementById("css");<br/>                  var oHour=document.getElementById("hour");<br/>                  var oMin=document.getElementById("min");<br/>                  var oSec=document.getElementById("sec");<br/>                  var aLi="";<br/>                  var sCss="";<br/>                  for(var i=0;i<60;i++)<br/>                    {<br/>                          sCss+="#wrap ul li:nth-of-type("+(i+1)+"){ -webkit-transform:rotate("+i*6+"deg);}";<br/>                          aLi+="<li>"<br/>                    }<br/>                  oList.innerHTML=aLi;<br/>                  oCss.innerHTML+=sCss;<br/>                  toTime();<br/>                  setInterval(toTime,1000);<br/>                  function toTime()<br/>                      {<br/>                            var oDate=new Date();<br/>                            var iSec=oDate.getSeconds();<br/>                            var iMin=oDate.getMinutes()+iSec/60;<br/>                            var iHour=oDate.getHours()+iMin/60;<br/>                            oSec.style.WebkitTransform="rotate("+iSec*6+"deg)";<br/>                            oMin.style.WebkitTransform="rotate("+iMin*6+"deg)";<br/>oHour.style.WebkitTransform = "rotate("+iHour*30+"deg)"; <br/>##For more articles related to css3 transition and 2d transformation, please pay attention to the PHP Chinese website! <br/></script>
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
Iterating a React Design with Styled ComponentsIterating a React Design with Styled ComponentsApr 21, 2025 am 11:29 AM

In a perfect world, our projects would have unlimited resources and time. Our teams would begin coding with well thought out and highly refined UX designs.

Oh, the Many Ways to Make Triangular Breadcrumb Ribbons!Oh, the Many Ways to Make Triangular Breadcrumb Ribbons!Apr 21, 2025 am 11:26 AM

Oh, the Many Ways to Make Triangular Breadcrumb Ribbons

SVG Properties in CSS GuideSVG Properties in CSS GuideApr 21, 2025 am 11:21 AM

SVG has its own set of elements, attributes and properties to the extent that inline SVG code can get long and complex. By leveraging CSS and some of the forthcoming features of the SVG 2 specification, we can reduce that code for cleaner markup.

A Few Functional Uses for Intersection Observer to Know When an Element is in ViewA Few Functional Uses for Intersection Observer to Know When an Element is in ViewApr 21, 2025 am 11:19 AM

You might not know this, but JavaScript has stealthily accumulated quite a number of observers in recent times, and Intersection Observer is a part of that

Revisting prefers-reduced-motionRevisting prefers-reduced-motionApr 21, 2025 am 11:18 AM

We may not need to throw out all CSS animations. Remember, it’s prefers-reduced-motion, not prefers-no-motion.

How to Get a Progressive Web App into the Google Play StoreHow to Get a Progressive Web App into the Google Play StoreApr 21, 2025 am 11:10 AM

PWA (Progressive Web Apps) have been with us for some time now. Yet, each time I try explaining it to clients, the same question pops up: "Will my users be

The Simplest Ways to Handle HTML IncludesThe Simplest Ways to Handle HTML IncludesApr 21, 2025 am 11:09 AM

It's extremely surprising to me that HTML has never had any way to include other HTML files within it. Nor does there seem to be anything on the horizon that

Change Color of SVG on HoverChange Color of SVG on HoverApr 21, 2025 am 11:04 AM

There are a lot of different ways to use SVG. Depending on which way, the tactic for recoloring that SVG in different states or conditions — :hover,

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

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.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools