1.transitions功能
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
div{
margin-top:150px;
background-color:#ffff00;
color:#000;
width:100px;
transition:transform,background-color 1s linear,color 1s linear,width 1s linear;
}
div:hover{
background-color:#f0f;
transform:rotate(45deg);
color:#fff;
width:200px;
}
</style>
</head>
<body>
<div>transition Demo</div>
</body>
</html>
2.animations功能
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
div{
background-color:red;
}
@-webkit-keyframes mycolor {
/* 开始帧 */
0%{
background-color:red;
}
/* 背景颜色变化帧-黄色 */
40%{
background-color:#ff0;
}
/* 背景颜色变化帧-蓝色 */
70%{
background-color:aqua;
}
/* 结束帧 */
100%{
background-color:red;
}
}
div:hover{
-webkit-animation:mycolor 5s linear;
}
</style>
</head>
<body>
<div>示例文字</div>
</body>
</html>
3.实现多个属性值同时改变的动画
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
div{
position:absolute;
background-color:#ff0;
top:100px;
width:500px;
}
@-webkit-keyframes mycolor {
0%{
background-color:red;
transform:rotate(0deg);
}
30%{
background-color:aqua;
transform:rotate(30deg);
}
60%{
background-color:lightskyblue;
transform:rotate(-30deg);
}
100%{
background-color:red;
transform:rotate(0deg);
}
}
div:hover{
-webkit-animation-name:mycolor;
-webkit-animation-duration:5s;
-webkit-animation-timing-function:linear;
}
</style>
</head>
<body>
<div>示例文字</div>
</body>
</html>