基于CSS3特效之动画:animation的应用 - 网站

基于CSS3特效之动画:animation的应用

分类:CSS_CSS3 答疑 - 常见问题 · 发布时间:2021-10-17 00:10 · 阅读:8592

本篇文章对CSS3中的animation的使用进行了详细的介绍,需要的朋友可以参考下

animation

渐变背景动画

复制代码
代码如下:

@-webkit-keyframes changeBg{
0%{background-color:#000;}
20%{background-color:#300;}
40%{background-color:#600;}
60%{background-color:#900;}
80%{background-color:#f00;}
}
@-moz-keyframes changeBg{
0%{background-color:#000;}
20%{background-color:#300;}
40%{background-color:#600;}
60%{background-color:#900;}
80%{background-color:#f00;}
}
@keyframes changeBg{
0%{background-color:#000;}
20%{background-color:#300;}
40%{background-color:#600;}
60%{background-color:#900;}
80%{background-color:#f00;}
}
.animation-1{ width:200px; height:30px; line-height:30px; text-align:center; background-color:#000; color:#fff; }
.animation-1:hover{ -webkit-animation:changeBg 2s linear; -moz-animation:changeBg 2s linear; animation:changeBg 2s linear; background-color:#f00; }

文字移动动画

复制代码
代码如下:

@-webkit-keyframes textMove{
0%{ padding-left:0px;}
20%{ padding-left:50px;}
40%{ padding-left:100px;}
50%{ padding-left:125px;}
60%{ padding-left:100px;}
80%{ padding-left:50px;}
}
@-moz-keyframes textMove{
0%{ padding-left:0px;}
20%{ padding-left:50px;}
40%{ padding-left:100px;}
50%{ padding-left:125px;}
60%{ padding-left:100px;}
80%{ padding-left:50px;}
}
@keyframes textMove{
0%{ padding-left:0px;}
20%{ padding-left:50px;}
40%{ padding-left:100px;}
50%{ padding-left:125px;}
60%{ padding-left:100px;}
80%{ padding-left:50px;}
}
.animation-2{ background-color:pink; padding:10px 0;}
.animation-2:hover{ -webkit-animation:textMove 2s linear; -moz-animation:textMove 2s linear; animation:textMove 2s linear;}

简单的复合动画

复制代码
代码如下:

/*由于代码较多,此处只附上加-webkit前缀*/
.animation-3{ position:relative; width:200px; height:100px; padding:10px; background-color:#ccc;}
.animation-3 p{ opacity:0;}
.txt-1{
margin-left:60px;
-webkit-animation:txt-1-move 2s ease-out;
-moz-animation:txt-1-move 2s ease-out;
animation:txt-1-move 2s ease-out;
}
@-webkit-keyframes txt-1-move{
0%{margin-left:0px;opacity:0;}
50%{margin-left:30px;opacity:1; -webkit-transform:skew(-15deg);}
70%{margin-left:35px;opacity:1;}
100%{margin-left:60px;opacity:0; -webkit-transform:skew(-30deg);}
}

.txt-2{
opacity:1;
height:36px;
margin-top:10px;
font:18px/36px "Microsoft Yahei";
-webkit-animation:txt-2-move 4s ease-out 4s;
-moz-animation:txt-2-move 4s ease-out 4s;
animation:txt-2-move 4s ease-out 4s;
}
@-webkit-keyframes txt-2-move{
0%{margin-left:0px; opacity:0;}
30%{margin-left:50px; opacity:1;}
35%{margin-left:55px; opacity:1;}
40%{margin-left:55px; opacity:1;}
41%{margin-left:55px; opacity:1; -webkit-transform:skew(-30deg)}
45%{margin-left:55px; opacity:1;}
50%{margin-left:50px; opacity:1;}
60%{margin-left:50px; opacity:.5;}
70%{margin-left:50px; opacity:1;}
80%{margin-left:50px; opacity:.5;}
90%{margin-left:50px; opacity:1;}
100%{margin-left:50px; opacity:1;}
}

.txt-3{
position:absolute;
bottom:10px;
right:0px;
margin-left:-60px;
-webkit-animation:txt-3-move 2s ease-out 2s;
-moz-animation:txt-3-move 2s ease-out 2s;
animation:txt-3-move 2s ease-out 2s;
}
@-webkit-keyframes txt-3-move{
0%{margin-right:0px; opacity:0;}
50%{margin-right:30px; opacity:1; -webkit-transform:skew(-15deg);}
70%{margin-right:35px; opacity:1;}
100%{margin-right:60px; opacity:0; -webkit-transform:skew(-30deg);}
}

标签:
CSS3 动画 Animation

相关文章

css3媒体查询中device-width和width的区别详解

这篇文章主要介绍了css3媒体查询中device-width和width的区别详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

CSS3媒体查询实现不同宽度的下不同内容的展示功能

这篇文章主要介绍了CSS3媒体查询实现不同宽度的下不同内容的展示功能,本章节我们将为大家演示一些多媒体查询实例,需要的朋友可以参考下

CSS3几种实现子容器水平垂直居中的方法

本文有几种方法可以实现容器与子容器水平垂直居中,主要包括Flexbox布局,position绝对定位+transform,表格布局,具有一定的参考价值,感兴趣的可以了解一下

css3实现文字首尾衔接跑马灯的示例代码

这篇文章主要介绍了css3实现文字首尾衔接跑马灯的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

CSS的浮动及清除浮动的5种方法介绍

这篇文章主要为大家介绍了CSS的浮动及清除浮动的5种方法介绍,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪

返回分类 返回首页