作为前端刚入门的小菜鸟,只想记录一下每天的小收获

对于animation动画

1.实现动画效果的组成:

(1)通过类似Flash的关键帧来声明一个动画

(2)在animation属性中调用关键帧声明的动画

2.animation是一个复合属性包括很多的子属性:

  animation-name:用来指定一个关键帧动画的名称,这个动画名必须对应一个@keyframes 规则。CSS 加载时会应用animation-name 指定的动画,从而执行动画。 

  animation-duration 用来设置动画播放所需的时间

  animation-timing-function 用来设置动画的播放方式,有一些值如下:

     速度由快到慢,然后逐渐变慢:ease

     速度越来越快,呈现加速状态:ease-in;

     速度越来越慢,呈现一种减速状态:ease-out

     先加速,在减速:ease-in-out

    匀速状态:linear

    自定义(三段赛贝尔曲线);cubic-bezier

  animation-delay 用来指定动画的延迟时间(一直循环的值:infinite)

  animation-iteration-count 用来指定动画播放的循环次数

  animation-direction 用来指定动画的播放方向(逆向:alternate)

  animation-play-state 用来控制动画的播放状态(停止:paused)

  animation-fill-mode 用来设置动画的时间外属性

      动画结束后不返回:forwards

      动画结束后迅速返回:backforwards

      根据情况产生前两个效果:base

      默认:normal;

  简写形式:animation: myani 1s ease 2 alternate 0s both;

3.为了兼容旧版本,需要加上相应的浏览器前缀,版本信息如下表:

Opera Firefox Chrome Safari IE

支持需带前缀15 ~ 29 5 ~ 15 4 ~ 42 4 ~ 8 无

支持不带前缀无16+ 43+ 无10.0+

//兼容完整版,Opera 在这个属性上加入webkit,所以没有-o-

-webkit-animation: myani 1s ease 2 alternate 0s both;

-moz-animation: myani 1s ease 2 alternate 0s both;

-ms-animation: myani 1s ease 2 alternate 0s both;

transition: all 1s ease 0s;

//@keyframes 也需要加上前缀

@-webkit-keyframes myani {...}

@-moz-keyframes myani {...}

@-o-keyframes myani {...}

@-ms-keyframes myani {...}

keyframes myani {...}

<下面的例子没有加上兼容性>

1.幻灯片式轮播图

<!--这里的幻灯片式是以插入图片来写的,也可以写成背景图片轮播,代码会更简洁一点-->

<div id="container">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
*{margin:0;padding:0;}

#container{
width:100%;
height:100px;
position:relative;
overflow:hidden;
} #container>:not(:first-child){
opacity:0;
} #container>:first-child{
width:300px;
height:100px;
position:absolute;
font-weight:bold;">mediumpurple;
animation-name:shuf1;
animation-duration:20s; /*动画执行时间*/
animation-timing-function:ease-in-out; /*动画执行方法:匀速*/
animation-iteration-count:infinite; /*动画执行次数*/
} #container>:nth-child(2){
width:300px;
height:100px;
position:absolute;
font-weight:bold;">palegreen;
animation-name:shuf2;
animation-duration:20s; /*动画执行时间*/
animation-timing-function:ease-in-out; /*动画执行方法:匀速*/
animation-iteration-count:infinite; /*动画执行次数*/
} #container>:nth-child(3){
width:300px;
height:100px;
poaition:absolute;
font-weight:bold;">pink;
animation-name:shuf3;
animation-duration:20s; /*动画执行时间*/
animation-timing-function:ease-in-out; /*动画执行方法:匀速*/
animation-iteration-count:infinite; /*动画执行次数*/
} #container>:nth-child(4){
width:300px;
height:100px;
poaition:absolute;
font-weight:bold;">lightskyblue;
animation-name:shuf4;
animation-duration:20s; /*动画执行时间*/
animation-timing-function:ease-in-out; /*动画执行方法:匀速*/
animation-iteration-count:infinite; /*动画执行次数*/
} #container>:nth-child(3){
width:300px;
height:100px;
poaition:absolute;
font-weight:bold;">yellowgreen;
animation-name:shuf5;
animation-duration:20s; /*动画执行时间*/
animation-timing-function:ease-in-out; /*动画执行方法:匀速*/
animation-iteration-count:infinite; /*动画执行次数*/
} #container>:nth-child(6){
width:300px;
height:100px;
poaition:absolute;
font-weight:bold;">darkgrey;
animation-name:shuf6;
animation-duration:20s; /*动画执行时间*/
animation-timing-function:ease-in-out; /*动画执行方法:匀速*/
animation-iteration-count:infinite; /*动画执行次数*/
} @keyframes shuf1 {
0% {opacity: 1;}
14%,28%,42%,56%,72%,86%,100%{opacity:0.5}
} @keyframes shuf2 {
0%,14% {opacity:0 ;}
28%{opacity:1;}
42%,56%,72%,86% ,100%{opacity:0;}
} @keyframes shuf3 {
0%,14% ,28%{opacity: 0;}
42% {opacity:1;}
56%,72%,86% ,100%{opacity:0;}
} @keyframes shuf4 {
0%,14% ,28%,42% {opacity: 0;}
56% {opacity:1;}
72%,86% ,100%{opacity:0;}
} @keyframes shuf5 {
0%,14% ,28%,42%,56% {opacity: 0;}
72% {opacity:1;}
86% ,100%{opacity:0;}
} @keyframes shuf6 {
0%,14% ,28%,42%,56%,72% {opacity: 0;}
86% {opacity:1; }
100%{opacity:0;}
}

2.水平轮播图

html代码处

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="case2.css">
</head>
<body>
<div id="main">
<div id="container">
<div></div>
<div></div>
<div></div>
</div>
</div>
</body>
</html>

css样式

*{margin:0;padding:0;}

#main{
width:1000px;
height:200px;
margin:0 auto;
border:1px solid black;
position:relative;
overflow:hidden;
} #container{
width:3000px;
height:200px;
border:1px solid black;
position:absolute;
top:0;
animation-name:a1;
animation-duration:30s;/*设置动画播放的时间*/
animation-timing-function:linear; /*设置动画的缓动状态*/
animation-iteration-count:infinite; /*设置动画的循环次数*/
animation-direction:alternate; /* 设置动画逆向运动*/
}
#container>div{
width:1000px;
height:200px;
float:left; } #container>:first-child{
font-weight:bold;">#65B053;
} #container>:nth-child(2){
font-weight:bold;">#59B7DF;
} #container>:nth-child(3){
font-weight:bold;">#E8E25D;
} @keyframes a1{
0%{margin-left:0;}
45%,50%{margin-left:-1000px;}/*设置每张图片的停留时间*/
95%,100%{margin-left:-2000px;}
}

CSS3——animation的基础(轮播图)的更多相关文章

  1. CSS3最简洁的轮播图

    <!DOCTYPE html> <html> <head> <title>CSS3最简洁的轮播图</title> <style> ...

  2. css3实现3D切割轮播图案例

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  3. css3+JS实现幻灯片轮播图

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  4. CSS3实现轮播图效果

    CSS3实现轮播图主要是由css:background-position和css3:animation实现.且实现此轮播需要一张四个图横着相连的图片. 注(Internet Explorer 10.F ...

  5. 纯CSS3实现轮播图

    前言 纯css3实现的轮播图效果,和JavaScript控制的相比,简单高效了很多,但是功能也更加单一,只有轮播不能手动切换. 用什么实现的呢?页面布局 + animation动画 HTML部分 &l ...

  6. 纯CSS3轮播图

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  7. css3实现轮播图

    css3动画属性简写: animation: name  duration  timing-function  delay  iteration-count  direction  fill-mode ...

  8. 前端基础功能,原生js实现轮播图实例教程

    轮播图是前端最基本.最常见的功能,不论web端还是移动端,大平台还是小网站,大多在首页都会放一个轮播图效果.本教程讲解怎么实现一个简单的轮播图效果.学习本教程之前,读者需要具备html和css技能,同 ...

  9. js 基础篇(点击事件轮播图的实现)

    轮播图在以后的应用中还是比较常见的,不需要多少行代码就能实现.但是在只掌握了js基础知识的情况下,怎么来用较少的而且逻辑又简单的方法来实现呢?下面来分析下几种不同的做法: 1.利用位移的方法来实现 首 ...

随机推荐

  1. PS 知识整理

    Ctrl+J键复制背景图层. ps怎样只让截取的一部分图旋转 https://jingyan.baidu.com/article/d45ad14877fc6e69542b8079.html 按Ctrl ...

  2. Windows下phpstudy配置tp5的nginx时遇到的奇葩问题

    nginx原来的配置: hosts已经配置好127.0.0.1 到tpdev1.net这个域名 最后结果 No input file specified. 解决方法: 找到原因了,竟然是root的分隔 ...

  3. 【JavaScript】EasyUIのForm的跨域提交问题解析

    昨日.プログラムを作るとき.一つの問題がありますが.皆に共有します. [問題] EasyUIのFormでURLを請求するとき.返却の値が取得できない. [ソース] var fnRegUser = fu ...

  4. 递归可视化之汉诺塔的动画实现(turtle海龟)

    import turtle class Stack: def __init__(self): self.items = [] def isEmpty(self): def push(self, ite ...

  5. 【noip模拟赛5】细菌 状压dp

    [noip模拟赛5]细菌   描述 近期,农场出现了D(1<=D<=15)种细菌.John要从他的 N(1<=N<=1,000)头奶牛中尽可能多地选些产奶.但是如果选中的奶牛携 ...

  6. Ubuntu ROS

    设置你的sources.list 将电脑设置为接受来自packages.ros.org的软件 sudo sh -c 'echo "deb http://packages.ros.org/ro ...

  7. Find out where to contain the smartforms

    Go to table E071 and give smarforms name and it will give the transport req for that. Run SE03, choo ...

  8. centos7+mariadb+防火墙,允许远程

    centos7 已安装mariadb,想要允许数据库远程==数据库权限允许+系统允许 mariadb:允许数据库用户在所有ip使用某个用户远程 GRANT ALL PRIVILEGES ON *(数据 ...

  9. vba多条件查询更新EXCEL数据导access数据库

    功能:根据项目号和步骤ID,更新指定步骤完成时间.这里里边要匹配两个条件一个是项目ID “”projectID“” 另一个是 “”StepID“” 步骤ID. Sub SaveFini() Dim r ...

  10. asp.net上传图片到服务器

    ASP.NET的FileUpload控件可用于上传文件到服务器.HoverTreeTop新增了一个“阅图”功能,图片就是用FileUpload上传的.阅图功能查看:http://hovertree.c ...