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

对于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. 使用quaggaJS识别图片中的条形码

    quaggaJS是一个纯JS的插件,用于识别图片中的条形码,很方便.一般用于移动端拍照识别,也可以在网页端上传图片识别. github下载地址 首先要指定正确格式的条形码,常见的条形码编码类型有EAN ...

  2. Java框架spring Boot学习笔记(五):Spring Boot操作MySQL数据库增、删、改、查

    在pom.xml添加一下代码,添加操作MySQL的依赖jar包. <dependency> <groupId>org.springframework.boot</grou ...

  3. 音视频处理概要 markdown

    最近要想办法把录制的音视频进行拼接. 比方说此次录制的视频有三段,通过高清直播编码器录制,录制下的标准为h.264 直接用ffmpeg简单拼接,音频会丢失,所以有了此次解决方案(有可能会繁琐,简单方案 ...

  4. 修改Windows server 时间同步

    1.关闭“与Internet时间同步”选项. 2.禁用Windows时间服务,并将其设置为手动. 3.禁用Hyper-v时间同步服务,并将其设置为手动,这个在Hyper-v软件上选中要修改的虚拟机,设 ...

  5. Servlet第一篇(Tomcat)

    Tomcat 什么是Tomcat Tomcat简单的说就是一个运行JAVA的网络服务器,底层是Socket的一个程序,它也是JSP和Serlvet的一个容器. 为什么我们需要用到Tomcat 提供能够 ...

  6. centos查看自启动服务

    1,查看自启动服务? 2,查看某服务的开机启动状态? 3,启动(关闭,重启,查看)某个服务? 4,设置开机启动或者关闭某个服务? 1,查看自启动服务? systemctl list-unit-file ...

  7. atom使用技巧

    文本 批量处理 正则 空格换成换行:Atom替换换行符直接[Ctrl]+[F],然后选择正则,输入\n

  8. video自定义

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

  9. promise之我见

    在我们平时的方法中有很多方法是promise封装的, 有些函数后边跟的then和catch 就是promise的方法,先看一下pormise的特点 (1)对象的状态不受外界影响.Promise对象代表 ...

  10. ubuntu16.04安装Navicate

    1.   http://download2.navicat.com/download/navicat100_mysql_en.tar.gz 2.   tar -zxvf  /home/rain/dow ...