css3动画记录篇
2016-12-30 20:45
162 查看
PC端动画过度变换的兼容情况,用前阅读如下:(移动端由于手机迭代快,所以移动开发可不必考虑)
(1)transform:Chrome、Safari、Opera、Firefox、IE9 分别需要前缀 -webkit-、-o-、-moz-,-ms-。
(2)transition:Chrome、Safari、Opera、Firefox分别需要前缀-webkit-、-o-、-moz-,IE9不支持此属性
(3)@keyframes
规则 animation 属性:Chrome、Safari、Opera、Firefox、IE9 分别需要前缀 -webkit-、-o-、-moz-,IE9对此均不支持
1,上下移动
[html] view
plain copy
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
<style>
.box{width: 100px;height: 100px;margin: 100px; background: yellow;}
/*以下是时间段的分布0%到%50就是说这之间占有一半(50%)的时间,即Y轴0px到Y轴-50px用时为2s的一半,效果为上下移动*/
@keyframes topBottomMove{
0% {
transform: translateY(0px);
}
50% {
transform: translateY(-50px);
}
100% {
transform: translateY(0px);
}
}
.box {
animation: topBottomMove 2s infinite ease-in-out;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
2、360°无限循环
[html] view
plain copy
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<style type="text/css">
*
{
margin:0;
padding:0;
text-align:center;
}
@keyframes myRotate{
from{
transform:rotate(0deg);
}
to{
transform:rotate(360deg);
}
}
#box
{
width:300px;
height:300px;
margin: 300px auto;
border-radius: 50%;
/*linear为直线的,infinite则表示无限的*/
animation:myRotate .8s linear infinite;
color: white;
background:black;
}
</style>
<div id="box">
ABC
</div>
</body>
</html>
3,放大缩小
[html] view
plain copy
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<style type="text/css">
*
{
margin:0;
padding:0;
text-align:center;
}
@keyframes mymove{
0% { transform: scale(1) }
25% { transform: scale(.8) }
50% { transform: scale(1.1) }
75% { transform: scale(.9) }
100% { transform: scale(1) }
}
/*如果在vue上使用,需要实现触发一次就执行一次的话,则可以用:class='{move:move}',.move{animation: mymove .5s infinite;},通过修改move的boolean值达到效果*/
#box
{
width:300px;
height:300px;
line-height: 300px;
margin: 300px auto;
border-radius: 50%;
font-size: 200px;
border: 5px solid red;
/*infinite则表示无限,ease-in-out则是执行一次*/
animation: mymove .5s infinite;
color: white;
background:black;
}
</style>
<div id="box">
A
</div>
</body>
</html>
(1)transform:Chrome、Safari、Opera、Firefox、IE9 分别需要前缀 -webkit-、-o-、-moz-,-ms-。
(2)transition:Chrome、Safari、Opera、Firefox分别需要前缀-webkit-、-o-、-moz-,IE9不支持此属性
(3)@keyframes
规则 animation 属性:Chrome、Safari、Opera、Firefox、IE9 分别需要前缀 -webkit-、-o-、-moz-,IE9对此均不支持
1,上下移动
[html] view
plain copy
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
<style>
.box{width: 100px;height: 100px;margin: 100px; background: yellow;}
/*以下是时间段的分布0%到%50就是说这之间占有一半(50%)的时间,即Y轴0px到Y轴-50px用时为2s的一半,效果为上下移动*/
@keyframes topBottomMove{
0% {
transform: translateY(0px);
}
50% {
transform: translateY(-50px);
}
100% {
transform: translateY(0px);
}
}
.box {
animation: topBottomMove 2s infinite ease-in-out;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
2、360°无限循环
[html] view
plain copy
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<style type="text/css">
*
{
margin:0;
padding:0;
text-align:center;
}
@keyframes myRotate{
from{
transform:rotate(0deg);
}
to{
transform:rotate(360deg);
}
}
#box
{
width:300px;
height:300px;
margin: 300px auto;
border-radius: 50%;
/*linear为直线的,infinite则表示无限的*/
animation:myRotate .8s linear infinite;
color: white;
background:black;
}
</style>
<div id="box">
ABC
</div>
</body>
</html>
3,放大缩小
[html] view
plain copy
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<style type="text/css">
*
{
margin:0;
padding:0;
text-align:center;
}
@keyframes mymove{
0% { transform: scale(1) }
25% { transform: scale(.8) }
50% { transform: scale(1.1) }
75% { transform: scale(.9) }
100% { transform: scale(1) }
}
/*如果在vue上使用,需要实现触发一次就执行一次的话,则可以用:class='{move:move}',.move{animation: mymove .5s infinite;},通过修改move的boolean值达到效果*/
#box
{
width:300px;
height:300px;
line-height: 300px;
margin: 300px auto;
border-radius: 50%;
font-size: 200px;
border: 5px solid red;
/*infinite则表示无限,ease-in-out则是执行一次*/
animation: mymove .5s infinite;
color: white;
background:black;
}
</style>
<div id="box">
A
</div>
</body>
</html>
相关文章推荐
- CSS3学习记录四(动画-变形)
- CSS3动画样式记录
- 利用html5/css3 动画效果,实现图片果冻抖动效果
- css3动画与动效--按钮元素动画效果
- CSS3动画
- CSS3 自定义动画(animation)
- CSS3 动画
- 使用HTML5 SVG和CSS3制作边框运动的动画效果
- css3的动画特效--动画序列(animation)
- CSS3动画animation相关属性与关键帧规则keyframes
- HTML5 SVG和CSS3超酷文字遮罩动画特效
- css3 动画
- CSS3-loading动画(一)
- CSS3 中的动画功能
- css3 animation动画对应属性解释
- CSS3中和动画有关的属性transform、transition 和 animation
- 【CSS3】设置动画时间外属性
- 基础理解2:CSS3按钮动画
- CSS3小模块hover左右交替互换动画
- css3 2d转换3d转换以及动画的知识点汇总