HTML5+Canvas+CSS3实现齐天大圣孙悟空腾云驾雾效果

2020-04-20 17:03:29易采站长站整理

使用HTML5的canvas画的孙悟空,CSS3画的白云飘飘。

效果图:

代码如下:

CSS Code复制内容到剪贴板

<!doctype html>   
<html>   
<head>   
<meta charset="utf-8">   
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">   
<meta name="description" content="">   
<meta name="viewport" content="width=device-width, initial-scale=1">   
<title>HTML5+CSS3实现齐天大圣腾云驾雾</title>   
<style type="text/css">   
* {   
margin: 0;   
padding: 0;   
border: 0;   
}   
html, body {   
margin: 0;   
}   
@-webkit-keyframes STAR-MOVE {   
from {   
background-position: 0% 0%;   
}   
to {   
background-position: 600% 0%;   
}   
}   
@keyframes STAR-MOVE {   
from {   
background-position: 0% 0%;   
}   
to {   
background-position: 600% 0%;   
}   
}   
.wall {   
position: absolute;   
top: 0;   
left: 0;   
bottombottom: 0;   
rightright: 0;   
}   
div#background {   
background: black url(‘http://hovertree.com/texiao/html5/30/img/background.png’) repeat-x 5% 0%;   
background-size: cover;   
-webkit-animation: STAR-MOVE 200s linear infinite;   
-moz-animation: STAR-MOVE 200s linear infinite;   
-ms-animation: STAR-MOVE 200s linear infinite;   
animation: STAR-MOVE 200s linear infinite;   
}   
div#midground {   
background: url(‘http://hovertree.com/texiao/html5/30/img/midground.png’)repeat 20% 0%;   
z-index: 1;   
-webkit-animation: STAR-MOVE 100s linear infinite;   
-moz-animation: STAR-MOVE 100s linear infinite;   
-ms-animation: STAR-MOVE 100s linear infinite;   
animation: STAR-MOVE 100s linear infinite;