• CSS 动画


    css动画animate,各种动画效果。

    小部分效果:

    这个css动画原网站http://daneden.me/animate

    例子代码:

    <!DOCTYPE html>
    <html>
    <head>
    	<meta charset="utf-8" />
    	<link rel="stylesheet" href="css/animate.css">
    	<script src="js/jquery.2.1.4.min.js"></script>
    	<title>CSS动画</title>
    	<style>
    		#animationSandbox {
    			height: 300px;
    			line-height: 300px;
    			font-weight: bold;
    			font-size: 80px;
    			text-align: center;
    		}
    		div {
    			text-align: center;
    		}
    	</style>
    </head>
    
    <body>
    	<div id="animationSandbox">Animates</div>
    	<div>
    		<select class="js-animations">
    			<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>
    		<button class="js-triggerAnimation">动画</button>
    	</div>
    	
    	<script>
    		//设置动画结束移除样式
    		function testAnim(x) {
    			//动画开始事件
    			$('#animationSandbox').one('webkitAnimationStart mozAnimationStart MSAnimationStart oanimationstart animationstart', function() {
    				$("body").css("overflow", "hidden");
    			});
    			//removeClass()移除所有class,再添加动画class  infinite:无限次
    			//.one:绑定一次性事件(即执行一次的事件)  
    			//动画结束移除动画事件:webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend
    			$('#animationSandbox').removeClass().addClass(x + ' animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
    				$(this).removeClass();
    				$("body").css("overflow", "auto");
    			});
    		};
    		$(document).ready(function() {
    			
    			//点击按钮设置动画
    			$('.js-triggerAnimation').click(function(e) {
    				e.preventDefault();
    				var anim = $('.js-animations').val();
    				testAnim(anim);//设置动画,结束移除样式
    			});
    			
    			//选择样式下拉框后设置动画
    			$('.js-animations').change(function() {
    				var anim = $(this).val();
    				testAnim(anim);//设置动画,结束移除样式
    			});
    			
    		});
    	</script>
    	
    </body>
    </html>

    CSS动画

    1、animated(animation-duration: 1.3s; 持续时间,animation-fill-mode: both;动画播放前后动画效果)

    2、动画开始事件

    3、动画结束移除动画事件

    4、css代码实现动画主要几个属性:
        animation-duration: 1.3s; /* 持续时间 */
        animation-fill-mode: both; /* 规定动画在播放之前或之后,其动画效果是否可见 */
        animation-iteration-count: infinite; /* 动画的播放次数:infinite-无限次 */
        animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); /* 动画的速度曲线 */
        transform: translate3d(0, 0, 0); /* 设置对元素进行旋转、缩放、移动或倾斜 */
        transform-origin: center bottom; /* 改变被转换元素的位置 */
        animation-name: bounce; /* 为 @keyframes 动画规定名称 */
        @keyframes xxx /* 动画实现主要属性,创建动画的原理是,将一套 CSS 样式逐渐变化为另一套样式,以百分比来规定改变发生的时间 */
        from,to /* "from"等价于0%; "to"等价于100% */
        opacity: 0; /* 透明度 */
        visibility: visible; /* 是否可见 */
        
        visibility: hidden; /* 占空间 */
        display: none; /* 不占空间 */

        代码下载

  • 相关阅读:
    IDEA 配置
    从一个多项目Web工程看Eclipse如何导入Gradle项目
    mac java环境变量配置
    gradle多项目构建及依赖
    gradle新建工程,多项目依赖,聚合工程
    JSTL的一些使用规范,坑
    mysql主从配置
    windows系统常用软件及配置介绍
    mac必装工具以及mac使用介绍
    一种480 MHz无线数传模块的设计
  • 原文地址:https://www.cnblogs.com/qq1995/p/10358997.html
Copyright © 2020-2023  润新知