1. Timing-function: steps()
At first, I didn’t pay much attention to this timing-function when using CSS3. Notice the custom Bezier curve.
1) Example in a project
Let’s first look at the difference between adding steps on the left and not adding them on the right. The one on the left is hammer after hammer, and a shadow will appear on the right.
[Note that the following demo cannot be executed in Firefox, but can only be executed in Chrome, because I am animating the "background-image" attribute 】
The code is as follows. I only posted the key codes. For details, you cansee here:
.btn-pay { background: url(t_btn-pay.png) no-repeat -30px; animation: pay-interval 0.5s steps(1) infinite; } .btn-pay2 { animation: pay-interval 0.5s linear infinite; } @keyframes pay-interval { from { background-image: url(t_btn-pay.png); } 30% { background-image: url(t_btn-pay-active.png); } to { background-image: url(t_btn-pay.png); } }
2) Parameter description
The syntax is as follows:
a. The first parameter specifies the number of intervals in the time function (must be a positive integer). This number of intervals is used between two key frames, that is, form and 30% between, between 30% and to.
b. The second parameter is optional and accepts two values: start and end, specifying a step change at the starting point or end point of each interval. The default is end.
I set 1 in CSS (there is not much difference between start and end in this example), which is a step-by-step animation. If not set, there will actually be multiple steps in it. operation, a shadow will appear.
There is an example written in a foreign article that can distinguish the difference between these two values. The demo link can be clicked here, and the specific principles can be searched online. .
.contain-car { animation: drive 4s steps(4, end) infinite; } .contain-car-2 { animation: drive 4s steps(4, start) infinite; }
3) Create animation through sprite pictures
Through the synthesized pictures, and then Set an interval number, and animation will appear. For example, the loading picture below, click to view Online demo.
## 2. animation-direction
animation-direction defines whether the animation should be played in reverse in turn. The options are normal, alternate, reverse, etc.
1) Example in a project
The jitter on the left is obviously much smoother, while the jitter on the right is smooth after 100% completion. Jump back to 0% state.
The code is as follows. I only posted the key codes. For details, you cancheck here:
.img1 { animation: tel-rotate 1s linear infinite alternate; } .img2 { animation: tel-rotate 1s linear infinite; } @keyframes tel-rotate { from { -webkit-transform: rotate(-20deg); transform: rotate(-20deg); } to { -webkit-transform: rotate(40deg); transform: rotate(40deg); } }
2) CSS3 animation frame number calculator
When I was doing this dithering, I didn’t notice this property at first, but later I found it. Such a CSS3 animation frame number calculator.
And noticed that the animation scrolling back and forth in this is very smooth. The calculation of key frames is very particular, and there are some algorithms in it. There is also a lot of relevant information on the Internet.
3. Timing-function: cubic-bezier()
Customize the Bezier curve function. By setting four parameters, you can control the speed of the animation.
The commonly used ease, linear, ease-in, etc. are actually the results obtained after inputting four parameters.
1) An online example
Through customization, you can organize more complex synthetic animations, such as the scene of the ball falling to the ground, click View Online Code.
When I saw this example, I was quite shocked. I always thought that this kind of animation needs to be coordinated with JavaScript.
The picture comes from "Twelve Principles of Web Animation". This article was translated from abroad. The principles inside are summarized by Disney Animation.
2) Bezier auxiliary tools
On the easings.net page, you can view various easing effects.
In cubic-bezier.com, you can make it online. Drag the two red or blue dots to automatically display the corresponding parameter.
The above is the detailed content of Powerful applications of several CSS3 properties that go unnoticed. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

Clothoff.io
AI clothes remover

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

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)

TogetintliteralattributeinsteadofSyntaxError,useaspaceorparenthesis.TheintliteralisapartifNumericLiteralsinPython.NumericLiteralsalsoincludesthefollowingfourdifferentnumericaltypes?int(signedintegers)?Theyareoftencalledjustintegersorints,arepositiveo

The Gson@SerializedName annotation can be serialized to JSON and have the provided name value as its field name. This annotation can override any FieldNamingPolicy, including the default field naming policy that may have been set on the Gson instance. Different naming strategies can be set using the GsonBuilder class. Syntax@Retention(value=RUNTIME)@Target(value={FIELD,METHOD})public@interfaceSerializedNameExample importcom.google.gson.annotations.*;

Python's dir() function: View an object's properties and methods, specific code example required Summary: Python is a powerful and flexible programming language, and its built-in functions and tools provide developers with many convenient features. One of the very useful functions is the dir() function, which allows us to view the properties and methods of an object. This article will introduce the usage of the dir() function and demonstrate its functions and uses through specific code examples. Text: Python’s dir() function is a built-in function.

In CSS, you can use the border-image attribute to achieve a lace border. The border-image attribute can use images to create borders, that is, add a background image to the border. You only need to specify the background image as a lace style; the syntax "border-image: url (image path) offsets the image border width inward. Whether outset is repeated;".

What should I do if the disk properties of Win11 are unknown? Recently, Win11 users found that the system prompted a disk error when using their computers. What is going on? And how to solve it? Many friends don’t know how to operate in detail. The editor has compiled the steps to solve the Win11 disk error below. If you are interested, follow the editor to read below! Steps to solve Win11 disk error 1. First, press the Win+E key combination on the keyboard, or click the File Explorer on the taskbar; 2. In the right sidebar of the File Explorer, find the side and right-click the local disk (C :), in the menu item that opens, select Properties; 3. Local disk (C:) Properties window, switch to Tools

Thread of Despair is a rare card in Blizzard Entertainment's masterpiece "Hearthstone" and has a chance to be obtained in the "Wizbane's Workshop" card pack. Can consume 100/400 arcane dust points to synthesize the normal/gold version. Introduction to the attributes of Hearthstone's Thread of Despair: It can be obtained in Wizbane's workshop card pack with a chance, or it can also be synthesized through arcane dust. Rarity: Rare Type: Spell Class: Death Knight Mana: 1 Effect: Gives all minions a Deathrattle: Deals 1 damage to all minions

If you want to get the pixels to which the document is scrolled from the upper left corner of the window, use the pageXoffset and pageYoffset properties. Use pageXoffset for horizontal pixels. Example You can try running the following code to learn how to use the pageXOffset attribute in JavaScript - Live Demonstration<!DOCTYPEhtml><html>?<head>?<style> &

How to tell if a jQuery element has a specific attribute? When using jQuery to operate DOM elements, you often encounter situations where you need to determine whether an element has a specific attribute. In this case, we can easily implement this function with the help of the methods provided by jQuery. The following will introduce two commonly used methods to determine whether a jQuery element has specific attributes, and attach specific code examples. Method 1: Use the attr() method and typeof operator // to determine whether the element has a specific attribute
