body {
background-color: #f7f7f7;
}
#game-container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
#target {
width: 100px;
height: 100px;
background-color: red;
position: absolute;
cursor: pointer;
}
#score {
font-size: 24px;
text-align: center;
margin-top: 20px;
}
这是一个简单的HTML小游戏代码,游戏页面中央有一个红色方块,玩家需要点击该方块以增加分数。游戏开始后,方块会随机移动到页面的任意位置。每次玩家点击方块后,方块会再次随机移动。玩家的分数会在页面上显示。
咨询微信客服
0516-6662 4183
立即获取方案或咨询top