原生js实现贪吃蛇小游戏效果代码
代码语言:html
所属分类:游戏
代码描述:原生js实现贪吃蛇小游戏效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
html,
body {
height: 100%;
margin: 0;
}
body {
--size: 15px;
--color: black;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
color: var(--color);
background-color: #ff8585;
background: linear-gradient(
162deg,
rgba(255, 133, 133, 1) 0%,
rgba(227, 84, 95, 1) 100%
);
}
footer {
font-size: 0.8em;
}
@media (min-height: 425px) {
body {
--size: 25px;
}
footer {
height: 40px;
font-size: 1em;
}
}
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100%;
}
header {
display: flex;
justify-content: space-between;
width: calc(var(--size) *17);
font-size: 2em;
font-weight: 900;
}
.grid {
display: grid;
grid-template-columns: repeat(15, auto);
grid-template-rows: repeat(15, auto);
border: var(--size)solid var(--color);
}
.tile {
position: relative;
width: var(--size);
height: var(--size);
}
.content {
position: absolute;
width: 100%;
height: 100%;
}
footer {
margin-top: 20px;
max-width: calc(var(--size) *17);
text-align: center;
}
footer a:visited {
color: inherit;
}
</style>
</head>
<body translate="no">
<div class="container">
<header>
<div class="contrast">
100%
</div>
<div class="score">
0
</div>
</header>
<div class="grid"></div>
<footer>
Press an arrow key or space to start!
<div>
Re.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0