您的当前位置:首页正文

css动画教程

2020-11-27 来源:赴品旅游

本篇文章主要向大家介绍如何使用css制作简单的动画,感兴趣的小伙伴参考下.

案例一:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Gxl网</title> 
<style> 
div
{
	width:100px;
	height:100px;
	background:red;
	animation:myfirst 5s;
	-moz-animation:myfirst 5s; /* Firefox */
	-webkit-animation:myfirst 5s; /* Safari and Chrome */
	-o-animation:myfirst 5s; /* Opera */
}

@keyframes myfirst
{
	0% {background:red;}
	25% {background:yellow;}
	50% {background:blue;}
	100% {background:green;}
}

@-moz-keyframes myfirst /* Firefox */
{
	0% {background:red;}
	25% {background:yellow;}
	50% {background:blue;}
	100% {background:green;}
}

案例二:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Gxl网</title> 
<style> 
div
{
	width:100px;
	height:100px;
	background:red;
	position:relative;
	animation:myfirst 5s;
	-webkit-animation:myfirst 5s; /* Safari and Chrome */
}

@keyframes myfirst
{
	0% {background:red; left:0px; top:0px;}
	25% {background:yellow; left:200px; top:0px;}
	50% {background:blue; left:200px; top:200px;}
	75% {background:green; left:0px; top:200px;}
	100% {background:red; left:0px; top:0px;}
}

@-webkit-keyframes myfirst /* Safari and Chrome */
{
	0% {background:red; left:0px; top:0px;}
	25% {background:yellow; left:200px; top:0px;}
	50% {background:blue; left:200px; top:200px;}
	75% {background:green; left:0px; top:200px;}
	100% {background:red; left:0px; top:0px;}
}
</style>
</head>
<body>

相关推荐:

PHP全站开发工程师-扩展之CSS动画和animate.css和wow.js

vue的css动画

用css实现css动画的暂停与播放功能教程

显示全文