Table of Contents
CSS3 Animation
1. CSS3 @keyframes rule
2. CSS3 animation properties
3. animation-timing-function attribute
5.       animation-play-state 属性
6.       属性简写
7.       Animate.css插件
8.       Wow.js插件
Home Backend Development PHP Tutorial PHP full-site development engineer - extended CSS animation, animate.css and wow.js

PHP full-site development engineer - extended CSS animation, animate.css and wow.js

Apr 09, 2018 pm 05:19 PM
css javascript engineer

The content of this article is shared with you by PHP full-site development engineer-extended CSS animation, animate.css and wow.js. Friends in need can refer to it


CSS3 Animation


CSS3, we can create animations, which can replace many web page animated images, Flash animations, and JAVAScripts.

1. CSS3 @keyframes rule

@keyframes A CSS style and animation specified in the rule will gradually change from the current style to the new style.

2. CSS3 animation properties


Specifies 3##animation-duration##animation-timing- function "ease"##animation-delay.

#Properties

Description

CSS

@keyframes

Specifies animation.

3

##animation

Shorthand property for all animation properties except the

animation-play-state property.

3

##animation-name

@keyframes The name of the animation.

#Specifies the seconds or milliseconds it takes for the animation to complete one cycle. The default is
0

.

3

specifies the speed curve of the animation. The default is

. 3

#Specifies when the animation starts. The default is

0
.

3

##animation-iteration- count

specifies the number of times the animation is played. The default is 1

Infinite:Infinite loop##3

animation-direction

##Specifies whether the animation plays in reverse in the next cycle. The default is "normal".

3

##animation-play- state

Specifies whether the animation is running or paused. The default is

"running".

3


3. animation-timing-function attribute


##Default. The animation starts at a slow speed, then speeds up, then slows down before ending. ease-inThe animation starts at a low speed. ease-outThe animation ends at low speed. ##ease-in-out#cubic-bezier(n, cubic-bezier

## Value

Description

##linear

The speed of the animation is the same from beginning to end.

ease

Animation at low speed Beginning and ending.

n

,n,n) its own value in the

function. Possible values ​​are numeric values ​​from 0 to 1 .

#Example: demo01

<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			p {
				width: 100px;
				height: 50px;
				background: red;
				color: white;
				font-weight: bold;
				position: relative;
				animation: mymove 5s;
				-webkit-animation: mymove 5s;
			}
			
			#p1 {animation-timing-function: linear; }
			
			#p2 {animation-timing-function: ease; }
			
			#p3 {animation-timing-function: ease-in; }
			
			#p4 {animation-timing-function: ease-out; }
			
			#p5 {animation-timing-function: ease-in-out; }
			
			#p1 {-webkit-animation-timing-function: linear; }
			
			#p2 {-webkit-animation-timing-function: ease; }
			
			#p3 {-webkit-animation-timing-function: ease-in; }
			
			#p4 {-webkit-animation-timing-function: ease-out; }
			
			#p5 {-webkit-animation-timing-function: ease-in-out; }
			
			@keyframes mymove {
				from {left: 0px; }
				to {left: 300px; }
			}
			
			@-webkit-keyframes mymove{
				from {left: 0px; }
				to {left: 300px; }
			}
		</style>
	</head>

	<body>

		<p id="p1">linear</p>
		<p id="p2">ease</p>
		<p id="p3">ease-in</p>
		<p id="p4">ease-out</p>
		<p id="p5">ease-in-out</p>

	</body>

</html>
Copy after login


The following effect is the same as the above example


Example: demo02

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8"> 
		<title></title> 
		<style> 
			p
			{
				width:100px;
				height:50px;
				background:red;
				color:white;
				font-weight:bold;
				position:relative;
				animation:mymove 5s infinite;
				-webkit-animation:mymove 5s infinite;
			}
			
			#p1 {animation-timing-function:cubic-bezier(0,0,0.25,1);}
			#p2 {animation-timing-function:cubic-bezier(0.25,0.1,0.25,1);}
			#p3 {animation-timing-function:cubic-bezier(0.42,0,1,1);}
			#p4 {animation-timing-function:cubic-bezier(0,0,0.58,1);}
			#p5 {animation-timing-function:cubic-bezier(0.42,0,0.58,1);}
			
			#p1 {-webkit-animation-timing-function:cubic-bezier(0,0,0.25,1);}
			#p2 {-webkit-animation-timing-function:cubic-bezier(0.25,0.1,0.25,1);}
			#p3 {-webkit-animation-timing-function:cubic-bezier(0.42,0,1,1);}
			#p4 {-webkit-animation-timing-function:cubic-bezier(0,0,0.58,1);}
			#p5 {-webkit-animation-timing-function:cubic-bezier(0.42,0,0.58,1);}
			
			@keyframes mymove
			{
				from {left:0px;}
				to {left:300px;}
			}
			
			@-webkit-keyframes mymove /* Safari and Chrome */
			{
				from {left:0px;}
				to {left:300px;}
			}
		</style>
	</head>
	<body>
	
		<p id="p1">linear</p>
		<p id="p2">ease</p>
		<p id="p3">ease-in</p>
		<p id="p4">ease-out</p>
		<p id="p5">ease-in-out</p>
	
	</body>
</html>
Copy after login

4.        animation-direction attribute



##value

##The animation plays in reverse. ##Animation in odd number of times (1, animation at odd times ( 1,

Description

##normal

default value. The animation plays as normal.

reverse

##alternate

, 3

5...) play forward, even times (2, 4, 6...) Reverse playback. alternate-reverse

, 3

5...) Reverse playback, in Even times (2, 4, 6...) forward Play.


5. animation-play-state 属性


描述

paused

指定暂停动画

running

指定正在运行的动画


实例:demo03

<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			p {
				width: 100px;
				height: 100px;
				background: red;
				position: relative;
				animation-name: myfirst;
				animation-duration: 5s;
				animation-timing-function: linear;
				animation-delay: 2s;
				animation-iteration-count: infinite;
				animation-direction: alternate;
				animation-play-state: running;
				-webkit-animation-name: myfirst;
				-webkit-animation-duration: 5s;
				-webkit-animation-timing-function: linear;
				-webkit-animation-delay: 2s;
				-webkit-animation-iteration-count: infinite;
				-webkit-animation-direction: alternate;
				-webkit-animation-play-state: running;
			}
			
			@keyframes myfirst {
				0% {
					background: red;
					left: 0px;
					top: 0px;
				}
				25% {
					background: yellow;
					left: 200px;
					top: 0px;
				}
				50% {
					background: blue;
					left: 200px;
					top: 200px;
				}
				75% {
					background: green;
					left: 0px;
					top: 200px;
				}
				100% {
					background: red;
					left: 0px;
					top: 0px;
				}
			}
			
			@-webkit-keyframes myfirst{
				0% {
					background: red;
					left: 0px;
					top: 0px;
				}
				25% {
					background: yellow;
					left: 200px;
					top: 0px;
				}
				50% {
					background: blue;
					left: 200px;
					top: 200px;
				}
				75% {
					background: green;
					left: 0px;
					top: 200px;
				}
				100% {
					background: red;
					left: 0px;
					top: 0px;
				}
			}
		</style>
	</head>

	<body>

		<p></p>

	</body>

</html>
Copy after login

6. 属性简写

与上面的动画相同,但是使用了简写的动画 animation 属性:


实例:demo04

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8"> 
		<title></title>
		<style> 
			p{
				width:100px;
				height:100px;
				background:red;
				position:relative;
				animation:myfirst 5s linear 2s infinite alternate;
				-moz-animation:myfirst 5s linear 2s infinite alternate;
				-webkit-animation:myfirst 5s linear 2s infinite alternate;
				-o-animation:myfirst 5s linear 2s infinite alternate;
			}
			
			@keyframes myfirst {
				0%   {background:red; left:0px; top:0px;}
				25%  {background:yellow; left:200px; top:0px;}
				50%  {background:blue; left:200px; top:200px;}
				75%  {background:green; left:0px; top:200px;}
				100% {background:red; left:0px; top:0px;}
			}
			
			@-moz-keyframes myfirst {
				0%   {background:red; left:0px; top:0px;}
				25%  {background:yellow; left:200px; top:0px;}
				50%  {background:blue; left:200px; top:200px;}
				75%  {background:green; left:0px; top:200px;}
				100% {background:red; left:0px; top:0px;}
			}
			
			@-webkit-keyframes myfirst {
				0%   {background:red; left:0px; top:0px;}
				25%  {background:yellow; left:200px; top:0px;}
				50%  {background:blue; left:200px; top:200px;}
				75%  {background:green; left:0px; top:200px;}
				100% {background:red; left:0px; top:0px;}
			}
			
			@-o-keyframes myfirst {
				0%   {background:red; left:0px; top:0px;}
				25%  {background:yellow; left:200px; top:0px;}
				50%  {background:blue; left:200px; top:200px;}
				75%  {background:green; left:0px; top:200px;}
				100% {background:red; left:0px; top:0px;}
			}
		</style>
	</head>
	<body>
	
		<p></p>
	
	</body>
</html>
Copy after login
7. Animate.css插件

Animate.css是某位大牛写好的动画效果集合,需要的时候可以直接下载导入到项目中,在需要的元素上添加相关的类即可使用相对应的动画效果。

Animate.css:源码版下载

Animate.min.css压缩版下载

如:

bounce


  • Animated:表示使用Animate.css的动画

  • Infinite:表示动画效果无限循环

  • Bounce:是动画效果

动画效果有很多,下面的案例就展示了各种动画效果


实例:demo05

<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/animate.min.css" />
		<style type="text/css">
			#content{
				padding-top: 20%;
			}
			#test {
				width: 50%;
				line-height: 100px;
				margin: auto;
				background-color: rgba(10, 10, 10, 0.2);
				text-align: center;
			}
			select{
				display: block;
				height: 45px;
				margin: auto;
			}
		</style>
		<script type="text/javascript">
			window.onload = function(){
				document.getElementById(&#39;select&#39;).onchange = function(){
					val = this.options[this.selectedIndex].value;
					document.getElementById(&#39;test&#39;).setAttribute(&#39;class&#39;,&#39;animated infinite &#39;+val);
				}
			}
		</script>
	</head>

	<body>
		<p id="content">
			<p id="test">bounce</p>
		</p>
		<select id="select">
			<optgroup label="Attention Seekers">
				<option value="bounce">bounce</option>
				<option value="flash">flash</option>
				<option value="pulse">pulse</option>
				<option value="rubberBand">rubberBand</option>
				<option value="shake">shake</option>
				<option value="swing">swing</option>
				<option value="tada">tada</option>
				<option value="wobble">wobble</option>
				<option value="jello">jello</option>
			</optgroup>

			<optgroup label="Bouncing Entrances">
				<option value="bounceIn">bounceIn</option>
				<option value="bounceInDown">bounceInDown</option>
				<option value="bounceInLeft">bounceInLeft</option>
				<option value="bounceInRight">bounceInRight</option>
				<option value="bounceInUp">bounceInUp</option>
			</optgroup>

			<optgroup label="Bouncing Exits">
				<option value="bounceOut">bounceOut</option>
				<option value="bounceOutDown">bounceOutDown</option>
				<option value="bounceOutLeft">bounceOutLeft</option>
				<option value="bounceOutRight">bounceOutRight</option>
				<option value="bounceOutUp">bounceOutUp</option>
			</optgroup>

			<optgroup label="Fading Entrances">
				<option value="fadeIn">fadeIn</option>
				<option value="fadeInDown">fadeInDown</option>
				<option value="fadeInDownBig">fadeInDownBig</option>
				<option value="fadeInLeft">fadeInLeft</option>
				<option value="fadeInLeftBig">fadeInLeftBig</option>
				<option value="fadeInRight">fadeInRight</option>
				<option value="fadeInRightBig">fadeInRightBig</option>
				<option value="fadeInUp">fadeInUp</option>
				<option value="fadeInUpBig">fadeInUpBig</option>
			</optgroup>

			<optgroup label="Fading Exits">
				<option value="fadeOut">fadeOut</option>
				<option value="fadeOutDown">fadeOutDown</option>
				<option value="fadeOutDownBig">fadeOutDownBig</option>
				<option value="fadeOutLeft">fadeOutLeft</option>
				<option value="fadeOutLeftBig">fadeOutLeftBig</option>
				<option value="fadeOutRight">fadeOutRight</option>
				<option value="fadeOutRightBig">fadeOutRightBig</option>
				<option value="fadeOutUp">fadeOutUp</option>
				<option value="fadeOutUpBig">fadeOutUpBig</option>
			</optgroup>

			<optgroup label="Flippers">
				<option value="flip">flip</option>
				<option value="flipInX">flipInX</option>
				<option value="flipInY">flipInY</option>
				<option value="flipOutX">flipOutX</option>
				<option value="flipOutY">flipOutY</option>
			</optgroup>

			<optgroup label="Lightspeed">
				<option value="lightSpeedIn">lightSpeedIn</option>
				<option value="lightSpeedOut">lightSpeedOut</option>
			</optgroup>

			<optgroup label="Rotating Entrances">
				<option value="rotateIn">rotateIn</option>
				<option value="rotateInDownLeft">rotateInDownLeft</option>
				<option value="rotateInDownRight">rotateInDownRight</option>
				<option value="rotateInUpLeft">rotateInUpLeft</option>
				<option value="rotateInUpRight">rotateInUpRight</option>
			</optgroup>

			<optgroup label="Rotating Exits">
				<option value="rotateOut">rotateOut</option>
				<option value="rotateOutDownLeft">rotateOutDownLeft</option>
				<option value="rotateOutDownRight">rotateOutDownRight</option>
				<option value="rotateOutUpLeft">rotateOutUpLeft</option>
				<option value="rotateOutUpRight">rotateOutUpRight</option>
			</optgroup>

			<optgroup label="Sliding Entrances">
				<option value="slideInUp">slideInUp</option>
				<option value="slideInDown">slideInDown</option>
				<option value="slideInLeft">slideInLeft</option>
				<option value="slideInRight">slideInRight</option>
			</optgroup>
			
			<optgroup label="Sliding Exits">
				<option value="slideOutUp">slideOutUp</option>
				<option value="slideOutDown">slideOutDown</option>
				<option value="slideOutLeft">slideOutLeft</option>
				<option value="slideOutRight">slideOutRight</option>
			</optgroup>

			<optgroup label="Zoom Entrances">
				<option value="zoomIn">zoomIn</option>
				<option value="zoomInDown">zoomInDown</option>
				<option value="zoomInLeft">zoomInLeft</option>
				<option value="zoomInRight">zoomInRight</option>
				<option value="zoomInUp">zoomInUp</option>
			</optgroup>

			<optgroup label="Zoom Exits">
				<option value="zoomOut">zoomOut</option>
				<option value="zoomOutDown">zoomOutDown</option>
				<option value="zoomOutLeft">zoomOutLeft</option>
				<option value="zoomOutRight">zoomOutRight</option>
				<option value="zoomOutUp">zoomOutUp</option>
			</optgroup>

			<optgroup label="Specials">
				<option value="hinge">hinge</option>
				<option value="jackInTheBox">jackInTheBox</option>
				<option value="rollIn">rollIn</option>
				<option value="rollOut">rollOut</option>
			</optgroup>
		</select>
	</body>

</html>
Copy after login

8. Wow.js插件

Wow.js是javascript动画插件,经常配合animate.css一起使用。动画效果会在元素第一次出现在页面中时起作用。

wow.js:源码版下载

wow.min.js压缩版下载

Wow.js的使用方法


  • 引入wow.js

  • 在需要使用的元素上添加class=”wow”

  • 使用js初始化

实例:demo06

<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/animate.min.css" />
		<script src="js/wow.min.js" type="text/javascript" charset="utf-8"></script>
		<style type="text/css">
			#content {
				padding-top: 20%;
			}
			
			#test {
				width: 50%;
				line-height: 100px;
				margin: auto;
				background-color: rgba(10, 10, 10, 0.2);
				text-align: center;
			}
		</style>
		<script type="text/javascript">
			var wow = new WOW({
				boxClass: &#39;wow&#39;, // 动画使用的class
				animateClass: &#39;animated infinite&#39;, // 附加的class
				offset: 0, // 当元素进入页面多少位置的时候开始动画,默认0
				mobile: true, // 是否在移动设备上显示动画效果,默认true
				live: true, // 是否异步加载内容,默认true
				callback: function(box) {},
				scrollContainer: null
			});
			wow.init();
		</script>
	</head>

	<body>
		<p id="content">
			<p id="test" class="wow bounce">bounce</p>
		</p>
	</body>

</html>
Copy after login

相关推荐:

vscode(Visual Studio Code)配置PHP开发环境的方法(已测)_编程开发_软件教程








The above is the detailed content of PHP full-site development engineer - extended CSS animation, animate.css and wow.js. 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

Video Face Swap

Video Face Swap

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

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 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.

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.

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

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 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 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 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 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-

See all articles