PHP全站开发工程师-扩展之CSS动画和animate.css和wow.js

酷丽姑娘_7616

酷丽姑娘_7616

2018-04-09

2422人浏览

原创

本篇文章给大家分享的内容是php全站开发工程师-扩展之css动画和animate.css和wow.js ,有需要的朋友可以参考一下


CSS3 动画


CSS3,我们可以创建动画,它可以取代许多网页动画图像,Flash动画,和JAVAScripts。

1.       CSS3 @keyframes 规则

@keyframes规则内指定一个CSS样式和动画将逐步从目前的样式更改为新的样式。

2.       CSS3的动画属性


属性

描述

CSS

@keyframes

规定动画。

3

animation

所有动画属性的简写属性,除了 animation-play-state 属性。

3

animation-name

规定 @keyframes 动画的名称。

3

animation-duration

规定动画完成一个周期所花费的秒或毫秒。默认是 0。

3

animation-timing-function

规定动画的速度曲线。默认是 "ease"。

3

animation-delay

规定动画何时开始。默认是 0。

3

animation-iteration-count

规定动画被播放的次数。默认是 1。Infinite:无限循环

3

animation-direction

规定动画是否在下一周期逆向地播放。默认是 "normal"。

3

animation-play-state

规定动画是否正在运行或暂停。默认是 "running"。

3


3.       animation-timing-function 属性


值

描述

linear

动画从头到尾的速度是相同的。

ease

默认。动画以低速开始,然后加快,在结束前变慢。

ease-in

动画以低速开始。

ease-out

动画以低速结束。

ease-in-out

动画以低速开始和结束。

cubic-bezier(n,n,n,n)

在 cubic-bezier 函数中自己的值。可能的值是从 0 到 1 的数值。



实例:demo01

html>


	
		<meta><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><p>linear</p>
		<p>ease</p>
		<p>ease-in</p>
		<p>ease-out</p><div class="aritcle_card flexRow artxards">
											<div class="artcardd flexRow">
												<a class="aritcle_card_img" rel="nofollow" href="/xiazai/skill13273" title="Biome High-Performance JavaScript TypeScript Formatter and Linter"><img
														src="https://img.php.cn/upload/skill/001/246/273/6adaf20d79f23518.jpg" alt="Biome High-Performance JavaScript TypeScript Formatter and Linter" onerror="this.onerror='';this.src='/static/lhimages/moren/morentu.png'" ></a>
												<div class="aritcle_card_info flexColumn">
													<a rel="nofollow" href="/xiazai/skill13273" title="Biome High-Performance JavaScript TypeScript Formatter and Linter" class="overflowclass">Biome High-Performance JavaScript TypeScript Formatter and Linter</a>
													<p class="overflowclass">Biome 是一个基于 Rust 的高性能工具链,适用于 JavaScript、TypeScript、JSX、JSON、CSS 和 GraphQL,它将格式化和 linting 统一到一个工具中。具有 97% 的 Prettier 兼容性以及超过 450 条 lint 规则,Biome 以显著更快的执行速度取代了 ESLint 和 Prettier。</p>
												</div>
												<a rel="nofollow" href="/xiazai/skill13273" title="Biome High-Performance JavaScript TypeScript Formatter and Linter" class="aritcle_card_btn flexRow flexcenter"><b></b><span>下载</span>
												</a>
											</div>
										</div>
		<p>ease-in-out</p>

	



下面的效果和上面实例一样


实例:demo02

html>

	
		<meta> 
		<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><p>linear</p>
		<p>ease</p>
		<p>ease-in</p>
		<p>ease-out</p>
		<p>ease-in-out</p>
	
	
4.       animation-direction 属性


值

描述

normal

默认值。动画按正常播放。

reverse

动画反向播放。

alternate

动画在奇数次(1、3、5...)正向播放,在偶数次(2、4、6...)反向播放。

alternate-reverse

动画在奇数次(1、3、5...)反向播放,在偶数次(2、4、6...)正向播放。


5.       animation-play-state 属性


值

描述

paused

指定暂停动画

running

指定正在运行的动画


实例:demo03

html>


	
		<meta><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><p></p>

	

6.       属性简写

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


实例:demo04

html>

	
		<meta> 
		<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><p></p>
	
	
7.       Animate.css插件

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

 

Animate.css:源码版下载

Animate.min.css压缩版下载

 

如:

bounce


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

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

  • Bounce:是动画效果

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


实例:demo05

html>


	
		<meta><title></title><link><style>
			#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>
			window.onload = function(){
				document.getElementById('select').onchange = function(){
					val = this.options[this.selectedIndex].value;
					document.getElementById('test').setAttribute('class','animated infinite '+val);
				}
			}
		</script><p>
			</p><p>bounce</p>
		
		<select><optgroup>
<option>bounce</option>
<option>flash</option>
<option>pulse</option>
<option>rubberBand</option>
<option>shake</option>
<option>swing</option>
<option>tada</option>
<option>wobble</option>
<option>jello</option>
</optgroup>
<optgroup>
<option>bounceIn</option>
<option>bounceInDown</option>
<option>bounceInLeft</option>
<option>bounceInRight</option>
<option>bounceInUp</option>
</optgroup>
<optgroup>
<option>bounceOut</option>
<option>bounceOutDown</option>
<option>bounceOutLeft</option>
<option>bounceOutRight</option>
<option>bounceOutUp</option>
</optgroup>
<optgroup>
<option>fadeIn</option>
<option>fadeInDown</option>
<option>fadeInDownBig</option>
<option>fadeInLeft</option>
<option>fadeInLeftBig</option>
<option>fadeInRight</option>
<option>fadeInRightBig</option>
<option>fadeInUp</option>
<option>fadeInUpBig</option>
</optgroup>
<optgroup>
<option>fadeOut</option>
<option>fadeOutDown</option>
<option>fadeOutDownBig</option>
<option>fadeOutLeft</option>
<option>fadeOutLeftBig</option>
<option>fadeOutRight</option>
<option>fadeOutRightBig</option>
<option>fadeOutUp</option>
<option>fadeOutUpBig</option>
</optgroup>
<optgroup>
<option>flip</option>
<option>flipInX</option>
<option>flipInY</option>
<option>flipOutX</option>
<option>flipOutY</option>
</optgroup>
<optgroup>
<option>lightSpeedIn</option>
<option>lightSpeedOut</option>
</optgroup>
<optgroup>
<option>rotateIn</option>
<option>rotateInDownLeft</option>
<option>rotateInDownRight</option>
<option>rotateInUpLeft</option>
<option>rotateInUpRight</option>
</optgroup>
<optgroup>
<option>rotateOut</option>
<option>rotateOutDownLeft</option>
<option>rotateOutDownRight</option>
<option>rotateOutUpLeft</option>
<option>rotateOutUpRight</option>
</optgroup>
<optgroup>
<option>slideInUp</option>
<option>slideInDown</option>
<option>slideInLeft</option>
<option>slideInRight</option>
</optgroup>
<optgroup>
<option>slideOutUp</option>
<option>slideOutDown</option>
<option>slideOutLeft</option>
<option>slideOutRight</option>
</optgroup>
<optgroup>
<option>zoomIn</option>
<option>zoomInDown</option>
<option>zoomInLeft</option>
<option>zoomInRight</option>
<option>zoomInUp</option>
</optgroup>
<optgroup>
<option>zoomOut</option>
<option>zoomOutDown</option>
<option>zoomOutLeft</option>
<option>zoomOutRight</option>
<option>zoomOutUp</option>
</optgroup>
<optgroup>
<option>hinge</option>
<option>jackInTheBox</option>
<option>rollIn</option>
<option>rollOut</option>
</optgroup></select>

8.       Wow.js插件

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

 

wow.js:源码版下载

wow.min.js压缩版下载

 

Wow.js的使用方法


  • 引入wow.js

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

  • 使用js初始化

实例:demo06

html>


	
		<meta><title></title><link><script></script><style>
			#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>
			var wow = new WOW({
				boxClass: 'wow', // 动画使用的class
				animateClass: 'animated infinite', // 附加的class
				offset: 0, // 当元素进入页面多少位置的时候开始动画,默认0
				mobile: true, // 是否在移动设备上显示动画效果,默认true
				live: true, // 是否异步加载内容,默认true
				callback: function(box) {},
				scrollContainer: null
			});
			wow.init();
		</script><p>
			</p><p>bounce</p>
		
	

相关推荐:

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








php免费学习视频:立即使用
踏上前端学习之旅,开启通往精通之路!从前端基础到项目实战,循序渐进,一步一个脚印,迈向巅峰!

相关文章

PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载

相关标签:

javascript css

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

相关专题

更多
css3教程
css3教程

php中文网为大家提供css3教程合集,CSS3的语法是建立在CSS原先版本基础上的,它允许使用者在标签中指定特定的HTML元素而不必使用多余的class、ID或JavaScript。php中文网还为大家带来css3的相关下载资源、相关课程以及相关文章等内容,供大家免费下载使用。

2023.06.14

2220

10

有哪些css3渐变属性
有哪些css3渐变属性

css3中渐变属性有linear-gradient、radial-gradient、conic-gradient、repeating-linear-gradient、repeating-radial-gradient等。本专题为大家提供相关的文章、下载、课程内容,供大家免费下载体验。

2023.11.01

3746

5

counta和count的区别
counta和count的区别

Count函数用于计算指定范围内数字的个数,而CountA函数用于计算指定范围内非空单元格的个数。本专题为大家提供相关的文章、下载、课程内容,供大家免费下载体验。

2023.11.20

4028

5

class在c语言中的意思
class在c语言中的意思

在C语言中,"class" 是一个关键字,用于定义一个类。想了解更多class的相关内容,可以阅读本专题下面的文章。

2024.01.03

4736

7

python中class的含义
python中class的含义

本专题整合了python中class的相关内容,阅读专题下面的文章了解更多详细内容。

2025.12.06

326

9

js正则表达式
js正则表达式

php中文网为大家提供各种js正则表达式语法大全以及各种js正则表达式使用的方法,还有更多js正则表达式的相关文章、相关下载、相关课程,供大家免费下载体验。

2023.06.20

5096

8

js获取当前时间
js获取当前时间

JS全称JavaScript,是一种具有函数优先的轻量级,解释型或即时编译型的编程语言;它是一种属于网络的高级脚本语言,主要用于Web,常用来为网页添加各式各样的动态功能。js怎么获取当前时间呢?php中文网给大家带来了相关的教程以及文章,欢迎大家前来学习阅读。

2023.07.28

1475

5

js 字符串转数组
js 字符串转数组

js字符串转数组的方法:1、使用“split()”方法;2、使用“Array.from()”方法;3、使用for循环遍历;4、使用“Array.split()”方法。本专题为大家提供js字符串转数组的相关的文章、下载、课程内容,供大家免费下载体验。

2023.08.03

1958

5

js是什么意思
js是什么意思

JS是JavaScript的缩写,它是一种广泛应用于网页开发的脚本语言。JavaScript是一种解释性的、基于对象和事件驱动的编程语言,通常用于为网页增加交互性和动态性。它可以在网页上实现复杂的功能和效果,如表单验证、页面元素操作、动画效果、数据交互等。

2023.08.17

10643

11

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
WebStorm 官方调试文档
WebStorm 官方调试文档

共0课时 | 0人学习

React 教程
React 教程

共58课时 | 12.6万人学习

TypeScript 教程
TypeScript 教程

共19课时 | 6.8万人学习