<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>行走的精灵(css) animation</title>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<style type="text/css">
* {
margin: 0;
padding: 0;
}
html,
body {
width: 100%;
height: 100%;
}
body {
position: relative;
background-image: url(img/back.png);
background-size: auto 100%;
animation: hack 30s steps(2500) infinite;
}
.elf {
width: 200px;
height: 300px;
background-image: url(img/2.png);
position: absolute;
bottom: 150px;
left: calc(50% - 100px);
animation: elf 1s steps(1) infinite;
transform: translateX(150px) scaleX(-1);
}
@keyframes elf {
0% {
background-position: calc( -200px * 0);
}
12.5% {
background-position: calc( -200px * 1);
}
25% {
background-position: calc( -200px * 2);
}
37.5% {
background-position: calc( -200px * 3);
}
50% {
background-position: calc( -200px * 4);
}
62.5% {
background-position: calc( -200px * 5);
}
75% {
background-position: calc( -200px * 6);
}
87.5% {
background-position: calc( -200px * 7);
}
100% {
background-position: calc( -200px * 8);
}
}
@keyframes hack {
0% {
background-position: 0;
}
100% {
background-position: -100%;
}
}
</style>
</head>
<body>
<div class="elf"></div>
<audio autoplay="autoplay" loop="loop">
<source src="img/iw ix - 天空之城.mp3" />
</audio>
<script type="text/javascript" src="js/jquery.js"></script>
<!--<script>
$(function() {
for(var i =0; i<100 ;i++){
console.debug(i+"{background-position: calc(200px * "+i+");}")
}
});
</script>-->
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>行走的精灵(css) animation</title>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<style type="text/css">
* {
margin: 0;
padding: 0;
}
html,
body {
width: 100%;
height: 100%;
}
body {
position: relative;
background-image: url(img/back.png);
background-size: auto 100%;
animation: hack 30s steps(2500) infinite;
}
.elf {
width: 200px;
height: 300px;
background-image: url(img/2.png);
position: absolute;
bottom: 150px;
left: calc(50% - 100px);
animation: elf 1s steps(1) infinite;
transform: translateX(150px) scaleX(-1);
}
@keyframes elf {
0% {
background-position: calc( -200px * 0);
}
12.5% {
background-position: calc( -200px * 1);
}
25% {
background-position: calc( -200px * 2);
}
37.5% {
background-position: calc( -200px * 3);
}
50% {
background-position: calc( -200px * 4);
}
62.5% {
background-position: calc( -200px * 5);
}
75% {
background-position: calc( -200px * 6);
}
87.5% {
background-position: calc( -200px * 7);
}
100% {
background-position: calc( -200px * 8);
}
}
@keyframes hack {
0% {
background-position: 0;
}
100% {
background-position: -100%;
}
}
</style>
</head>
<body>
<div class="elf"></div>
<audio autoplay="autoplay" loop="loop">
<source src="img/iw ix - 天空之城.mp3" />
</audio>
<script type="text/javascript" src="js/jquery.js"></script>
<!--<script>
$(function() {
for(var i =0; i<100 ;i++){
console.debug(i+"{background-position: calc(200px * "+i+");}")
}
});
</script>-->
</body>
</html>