2048小游戏html+css代码

废话不多说直接上代码。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="2048.css">
</head>
<body>
    <p>
        SCORE:<span>0</span>
    </p>
    <div class="all">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
    </div>
    <div class="gameover">
        <p>
            GAME OVER!!!<br>
            SCORE:<span>0</span><br>
            <a href="">try again</a>
        </p>
    </div>
    <script src="2048.js"></script>
</body>
</html>

以下是css部分的代码

*{
    margin: 0;
    padding: 0;
}
p{
    font-size: 40px;
    font-weight: bold;
    width: 500px;
    margin: auto;
    padding: 40px 0;
}
.all{
    width: 500px;
    height: 500px;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    margin: auto;
    background: #bbada0;
    padding-top: 20px;
    border-radius: 10px;
}
.all div{
    width: 105px;
    height: 105px;
    font-size: 40px;
    font-weight: bold;
    
    border-radius: 5px;
    background: #ccc0b3;;
}
.gameover{
    display: none;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0,.3);
    text-align: center;
    line-height: 100px;
    position: absolute;
    top: 0;
}
.gameover p{
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -250px;
    margin-left: -250px;
    background: #fff;
    border-radius: 20px;
}
.gameover a{
    text-decoration: none;
    background: #9f8d77;
    padding: 15px;
    color: #fff;
}
.n2{background-color:#eee3da!important;color:#776e65!important;}
.n4{background-color:#ede0c8!important;color:#776e65!important}
.n8{background-color:#f2b179!important}
.n16{background-color:#f59563!important}
.n32{background-color:#f67c5f!important}
.n64{background-color:#f65e3b!important}
.n128{background-color:#edcf72!important}
.n256{background-color:#edcc61!important}
.n512{background-color:#9c0!important}
.n1024{background-color:#33b5e5!important;font-size:40px!important}
.n2048{background-color:#09c!important;font-size:40px!important}
.n4096{background-color:#a6c!important;font-size:40px!important}
.n8192{background-color:#93c!important;font-size:40px!important}
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值