Example code for implementing ellipse trajectory rotation using CSS3

Example code for implementing ellipse trajectory rotation using CSS3

Recently, the following effects need to be achieved

Initially, using css3D rotation to write, can only achieve the following effects

I can't turn all the circles to the front. I don't know if my operation is wrong or 3D rotation is not possible. If anyone knows, please enlighten me.

Since it cannot be realized in 3D, we can only turn to 2D. As long as we can realize the rotation according to the ellipse, it will be ok.

X-axis and Y-axis move within a rectangle

Path is a slash

 .ball {
    animation: 
      animX 2s linear infinite alternate,
      animY 2s linear infinite alternate
  }
@keyframes animX{
      0% {left: 0px;}
    100% {left: 500px;}
}
@keyframes animY{
      0% {top: 0px;}
    100% {top: 300px;}
} 

Setting animation delay

Set the Y-axis delay to half the animation duration. You can see that the motion trajectory becomes a diamond shape. It feels a bit better.

 .ball {
    animation: 
      animX 2s linear 0s infinite alternate,
      animY 2s linear -1s infinite alternate
  } 

Sets a cubic Bezier curve

 .ball {
    animation: 
      animX 2s cubic-bezier(0.36, 0, 0.64, 1) -1s infinite alternate,
      animY 2s cubic-bezier(0.36, 0, 0.64, 1) 0s infinite alternate
  }

Zoom in and out

In order to make it look three-dimensional, add scale attribute. The scale animation should be the sum of the time of the X-axis and the Y-axis.

.ball1 {
    animation: 
      animX 2s cubic-bezier(0.36, 0, 0.64, 1) -1s infinite alternate,
      animY 2s cubic-bezier(0.36, 0, 0.64, 1) 0s infinite alternate,
      scale 4s cubic-bezier(0.36, 0, 0.64, 1) 0s infinite alternate;
  }
 @keyframes scale {

    0% {
      transform: scale(0.7)
    }
    50% {
      transform: scale(1)
    }
    100% {
      transform: scale(0.7)
   }
 } 

Mission accomplished!

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

<<:  How to extract string elements from non-fixed positions in MySQL

>>:  How to wrap HTML title attribute

Recommend

How to perform query caching in MySQL and how to solve failures

We all know that we need to understand the proper...

MySQL's conceptual understanding of various locks

Optimistic Locking Optimistic locking is mostly i...

Detailed Tutorial on Installing MySQL 5.7 on RedHat 6.5

RedHat6.5 installation MySQL5.7 tutorial sharing,...

JavaScript BOM location object + navigator object + history object

Table of contents 1. Location Object 1. URL 2. Pr...

Mysql inner join on usage examples (must read)

Grammatical rules SELECT column_name(s) FROM tabl...

The difference between the four file extensions .html, .htm, .shtml and .shtm

Many friends who have just started to make web pag...

Example of how to adapt the Vue project to the large screen

A brief analysis of rem First of all, rem is a CS...

How to choose the format when using binlog in MySQL

Table of contents 1. Three modes of binlog 1.Stat...

Comprehensive understanding of line-height and vertical-align

Previous words Line-height, font-size, and vertica...

How to build sonarqube using docker

Table of contents 1. Install Docker 2. Install so...

Introduction to the use of CSS3 filter attribute

1. Introduction When writing animation effects fo...

Detailed description of common events and methods of html text

Event Description onactivate: Fired when the objec...

How to convert rows to columns in MySQL

MySQL row to column operation The so-called row-t...

Use of marker tags in CSS list model

This article mainly introduces the ::master pseud...