CSS3 Animation 基于 less 构建的 css3 动画库_html/css_WEB-ITnose

php中文网
发布: 2016-06-24 11:50:22
原创
1897人浏览过

LESS动画优点

· 快速开发css3动画

· 采用less mixins写法,不会生成冗余css

· 已加入主流浏览器前缀,保证最大兼容性

· LESS-Animation 部分mixins支持传参,自定义动画幅度

(PS:sublime的less2css插件可能不支持编译本库的一些新写法,建议使用官方less编译、考拉、前端构建工具等方式编译。交流群:145423956)

立即学习前端免费学习笔记(深入)”;

使用方法

本less文件主要包含两个功能:LESS-Prefixer和LESS-Animation。

· 下载 _animation.less 文件,git地址:

git@github.com:w3cmark/css3.git
登录后复制

  

无限画
无限画

千库网旗下AI绘画创作平台

无限画 43
查看详情 无限画

· 在主less文件引入_animation.less

@import "_animation.less";
登录后复制

  

LESS-Prefixer

LESS-Prefixer是一组LESS mixins,可以让你在写css3时,去掉书写各个浏览器的前缀,简化代码书写。

如何使用

· 假如你写css3的transition:

div{  -webkit-transition:all 0.2s ease-out;  -o-transition:all 0.2s ease-out;  -ms-transition:all 0.2s ease-out;  -moz-transition:all 0.2s ease-out;  transition:all 0.2s ease-out;}
登录后复制

  

· 引入 _animation.less 后的写法:

div{  .transition(all 0.2s ease-out);}
登录后复制

  

支持的属性

.transition(@arg).transition-delay(@delay).transition-duration(@duration).transition-property(@property).transition-timing-function(@function).transition-delay(@delay).transition-delay(@delay).transform(@arg).transform-origin(@args).transform-style(@style).rotate(@deg).scale(@factor).translate(@x,@y).translate3d(@x,@y,@z).translateHardware(@x,@y).animation(@arg).animation-delay(@delay).animation-direction(@direction).animation-duration(@duration).animation-fill-mode(@mode).animation-iteration-count(@count).animation-name(@name).animation-play-state(@state).animation-timing-function(@function).flex(@arg).flexbox().opacity(@number).box-shadow(@arg).box-sizing(@arg).border-color(@arg).border-image(@arg).border-radius(@arg).background-origin(@arg).background-clip(@arg).background-size(@arg).columns(@args).column-count(@count).column-gap(@gap).column-width(@width).column-rule(@args).gradient(@default, @start, @stop).linear-gradient-top(@default,@color1,@stop1,@color2,@stop2).linear-gradient-top(@default,@color1,@stop1,@color2,@stop2,@color3,@stop3).linear-gradient-top(@default,@color1,@stop1,@color2,@stop2,@color3,@stop3,@color4,@stop4).linear-gradient-left(@default,@color1,@stop1,@color2,@stop2).linear-gradient-left(@default,@color1,@stop1,@color2,@stop2,@color3,@stop3).linear-gradient-left(@default,@color1,@stop1,@color2,@stop2,@color3,@stop3,@color4,@stop4)
登录后复制

  

LESS-Animation

mixin直接引用

LESS-Animation 是一个基于less,集成一些基础动画的库(所包含的动画可以在上面效果预览),直接调用相应的动画mixins即可。

动画帧名和mixin名一致,方便调用。

· 栗子一:引用 bounce 动画,只需在所在元素节点加入 .bounce();

.bounce{  .bounce();  .animation(bounce 1s ease-in-out); } 
登录后复制

· 栗子二:引用 bounceIn 动画,只需在所在元素节点加入 .bounceIn();

.box{  .bounceIn();  .animation(bounceIn 1s linear infinite);}
登录后复制

mixin传参引用

ps:
· 新增部分传参功能,可以自定义动画幅度参数,实现同类型动画不同幅度;
· 传参功能不影响原来上面直接引用,参数都可为空,原来的动画幅度已经设为默认值;

具体动画名和参数说明

动画名 参数说明 栗子
.bounce(@t; @n) @t:抖动最小幅度(默认值4px);@n:动画帧名(默认值bounce) .bounce(5px; bounceA)
.pulse(@t; @n) @t:放大幅度(默认值1.05);@n:动画帧名(默认值pulse) .pulse(1.5; pulseA)
.shake(@x; @n) @x:抖动最小幅度(默认值10px);@n:动画帧名(默认值shake) .shake(20px; shakeA)
.swing(@d; @n) @d:旋转最小角度(默认值5deg);@n:动画帧名(默认值swing) .swing(5deg; swingA)
.wobble(@d; @n) @d:摇摆最小幅度(默认值1deg);@n:动画帧名(默认值wobble) .wobble(-2deg; wobbleA)
.fadeIn(@x; @y; @n) @x:x轴移动距离(默认值0);@y:y轴移动距离(默认值0);@n:动画帧名(默认值fadeIn) .fadeIn(-1000px; 0; fadeInA)
.fadeOut(@x; @y; @n) @x:x轴移动距离(默认值0);@y:y轴移动距离(默认值0);@n:动画帧名(默认值fadeOut) .fadeOut(-1000px; 0; fadeOutA)
.turnInDown(@p; @n) @p:perspective值,元素距视图的距离(默认值600px);@n:动画帧名(默认值turnInDown) .turnInDown(700px; turnInDownA)
.turnInUp(@p; @n) @p:perspective值,元素距视图的距离(默认值600px);@n:动画帧名(默认值turnInUp) .turnInUp(700px; turnInUpA)
.turnInLeft(@p; @n) @p:perspective值,元素距视图的距离(默认值600px);@n:动画帧名(默认值turnInLeft) .turnInLeft(700px; turnInLeftA)
.turnInRight(@p; @n) @p:perspective值,元素距视图的距离(默认值600px);@n:动画帧名(默认值turnInRight) .turnInRight(700px; turnInRightA)
.turnOutDown(@p; @n) @p:perspective值,元素距视图的距离(默认值600px);@n:动画帧名(默认值turnOutDown) .turnOutDown(700px; turnOutDownA)
.turnOutUp(@p; @n) @p:perspective值,元素距视图的距离(默认值600px);@n:动画帧名(默认值turnOutUp) .turnOutUp(700px; turnOutUpA)
.turnOutLeft(@p; @n) @p:perspective值,元素距视图的距离(默认值600px);@n:动画帧名(默认值turnOutLeft) .turnOutLeft(700px; turnOutLeftA)
.turnOutRight(@p; @n) @p:perspective值,元素距视图的距离(默认值600px);@n:动画帧名(默认值turnOutRight) .turnOutRight(700px; turnOutRightA)

更新日志

· 20150110 增加turn Entrances(出现)和turn Exits(消失)系列动画

· 20150120 部分新增动画animation的mixin支持传参

在线预览效果 http://www.w3cmark.com/animation/

HTML速学教程(入门课程)
HTML速学教程(入门课程)

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

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号