JavaScript制作颜色反转小游戏制作颜色反转小游戏
本文给大家分享的是一个JavaScript实现的颜色反转的小游戏的源码,非常的简单好玩,有需要的小伙伴可以参
考下
游戏规则:
单击方块,被单击的方块及相邻方块变色,当所有蓝色方块变为橙色时,完成任务,进入下一级。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>颜色翻转</title>
<meta name="description" content="">
<meta name="author" content="jiamengkai">
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
<link rel="shortcut icon" href="/favicon.ico">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<style type="text/css">
* {
margin: 0;
padding: 0;
font-family: "Microsoft yahei";
color: #000;
}
h1 {
margin: 10px 0;
font-size: 300%;
font-weight: bolder;
}
span {
display: block;
text-indent: 32px;
}
.title {
position: fixed;
top: 50%;
left: 50%;
width: 300px;
height: 600px;
margin: -300px 0 0 -500px;
}
.main {
position: fixed;
top: 50%;
left: 50%;
width: 600px;
height: 600px;
margin: -300px 0 0 -150px;
background: #555;
border-radius: 8px;
1border: 5px solid #555;
}
.blue, .orange {
margin: 5px;
}
.blue {
background: #099;
border-radius: 8px;
float: left;
}
.orange {
background: #D69C49;
border-radius: 8px;
float: left;
}
.button {
1display: inline-block;