* {
margin: 0;
padding: 0;
}
.container {
width: 500px;
height: 640px;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
font-family: "微软雅黑";
}
.header {
height: 120px;
margin-bottom: 20px;
}
.game-title {
font-size: 50px;
color: #776e65;
text-align: center;
margin-bottom: 10px;
}
.game-info {
height: 40px;
}
#game-score, #game-best-score {
height: 100%;
float: left;
min-width: 65px;
background-color: #bbada0;
color: #fff;
font-size: 18px;
border-radius: 5px;
text-align: center;
line-height: 58px;
position: relative;
}
#game-score:after {
content: "Score";
position: absolute;
width: 100%;
left: 0;
top: -21px;
text-align: center;
color: #e9dfd4;
font-size: 13px;
}
#game-best-score {
margin-right: 15px;
}
#game-best-score:after {
content: "Best";
position: absolute;
width: 100%;
left: 0;
top: -21px;
text-align: center;
color: #e9dfd4;
font-size: 13px;
}
#newGame {
height: 100%;
width: 100px;
float: right;
border-radius: 5px;
background-color: #8f7a66;
border: none;
box-shadow: none;
color: #fff;
font-size: 16px;
cursor: pointer;
}
#newGame:focus {
outline: none;
}
.game-container {
width: 500px;
height: 500px;
position: relative;
background-color: #bbada0;
padding: 15px;
border-radius: 5px;
box-sizing: border-box;
-moz-box-sizing: border-box;
/* Firefox */
-webkit-box-sizing: border-box;
/* Safari */
}
.gird-container {
width: 470px;
height: 470px;
}
.gird-row {
width: 470px;
height: 106.25px;
margin-bottom: 15px;
clear: both;
}
.gird-row:last-child {
margin-bottom: 0;
}
.gird-col {
width: 106.25px;
height: 106.25px;
margin-right: 15px;
background-color: #cdc1b4;
float: left;
}
.gird-col:last-child {
margin-right: 0;
}
.tile-container {
color: #f9f6f2;
width: 470px;
height: 470px;
position: absolute;
top: 15px;
}
.game-over {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 10;
background-color: rgba(204, 204, 204, 0.5);
}
.game-over:after {
content: "Game Over";
font-size: 60px;
color: #fff;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 70px;
margin: auto;
text-align: center;
}
.game-win {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 10;
background-color: rgba(204, 204, 204, 0.5);
}
.game-win:after {
content: "You Win";
font-size: 60px;
color: #fff;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 70px;
margin: auto;
text-align: center;
}
.game-win-again {
width: 160px;
height: 50px;
border-radius: 5px;
background-color: #8f7a66;
border: none;
box-shadow: none;
color: #fff;
cursor: pointer;
position: absolute;
bottom: 120px;
left: 0;
right: 0;
margin: auto;
font-size: 30px;
}
.game-win-again:after {
content: "Continue";
}
.tile {
position: absolute;
width: 106.25px;
height: 106.25px;
text-align: center;
line-height: 106.25px;
font-size: 50px;
top: 0;
transition: transform 150ms ease-out;
-moz-transition: transform 150ms ease-out;
/* Firefox 4 */
-webkit-transition: transform 150ms ease-out;
/* Safari 和 Chrome */
-o-transition: transform 150ms ease-out;
/* Opera */
animation: tiledisplay 300ms 1;
-webkit-animation: tiledisplay 300ms 1;
/* Safari 和 Chrome */
}
@keyframes tiledisplay {
0% {
opacity: 0;
filter: alpha(opacity=0);
}
50% {
opacity: 0;
filter: alpha(opacity=0);
}
100% {
opacity: 1;
filter: alpha(opacity=100);
}
}
@-webkit-keyframes tiledisplay
/* Safari and Chrome */
{
0% {
opacity: 0;
filter: alpha(opacity=0);
}
50% {
opacity: 0;
filter: alpha(opacity=0);
}
100% {
opacity: 1;
filter: alpha(opacity=100);
}
}
.tile-container .tile-2 {
color: #776e65;
background: #eee4da;
}
.tile-container .tile-4 {
color: #776e65;
background: #ede0c8;
}
.tile-container .tile-8 {
background: #f2b179;
}
.tile-container .tile-16 {
background: #f59563;
}
.tile-container .tile-32 {
background: #f67c5f;
}
.tile-container .tile-64 {
background: #f65e3b;
}
.tile-container .tile-128 {
background: #edcf72;
}
.tile-container .tile-256 {
background: #edcc61;
}
.tile-container .tile-512 {
background: #edc850;
}
.tile-container .tile-1024 {
background: #edc53f;
}
.tile-container .tile-2048 {
background: #edc22e;
}
.tile-container .tile-pos-0-0 {
-webkit-transform: translate(0, 0);
-ms-transform: translate(0, 0);
-o-transform: translate(0, 0);
transform: translate(0, 0);
}
.tile-container .tile-pos-0-1 {
-webkit-transform: translate(0, 121.25px);
-ms-transform: translate(0, 121.25px);
-o-transform: translate(0, 121.25px);
transform: translate(0, 121.25px);
}
.tile-container .tile-pos-0-2 {
-webkit-transform: translate(0, 242.5px);
-ms-transform: translate(0, 242.5px);
-o-transform: translate(0, 242.5px);
transform: translate(0, 242.5px);
}
.tile-container .tile-pos-0-3 {
-webkit-transform: translate(0, 363.75px);
-ms-transform: translate(0, 363.75px);
-o-transform: translate(0, 363.75px);
transform: translate(0, 363.75px);
}
.tile-container .tile-pos-1-0 {
-webkit-transform: translate(121.25px, 0);
-ms-transform: translate(121.25px, 0);
-o-transform: translate(121.25px, 0);
transform: translate(121.25px, 0);
}
.tile-container .tile-pos-1-1 {
-webkit-transform: translate(121.25px, 121.25px);
-ms-transform: translate(121.25px, 121.25px);
-o-transform: translate(121.25px, 121.25px);
transform: translate(121.25px, 121.25px);
}
.tile-container .tile-pos-1-2 {
-webkit-transform: translate(121.25px, 242.5px);
-ms-transform: translate(121.25px, 242.5px);
-o-transform: translate(121.25px, 242.5px);
transform: translate(121.25px, 242.5px);
}
.tile-container .tile-pos-1-3 {
-webkit-transform: translate(121.25px, 363.75px);
-ms-transform: translate(121.25px, 363.75px);
-o-transform: translate(121.25px, 363.75px);
transform: translate(121.25px, 363.75px);
}
.tile-container .tile-pos-2-0 {
-webkit-transform: translate(242.5px, 0);
-ms-transform: translate(242.5px, 0);
-o-transform: translate(242.5px, 0);
transform: translate(242.5px, 0);
}
.tile-container .tile-pos-2-1 {
-webkit-transform: translate(242.5px, 121.25px);
-ms-transform: translate(242.5px, 121.25px);
-o-transform: translate(242.5px, 121.25px);
transform: translate(242.5px, 121.25px);
}
.tile-container .tile-pos-2-2 {
-webkit-transform: translate(242.5px, 242.5px);
-ms-transform: translate(242.5px, 242.5px);
-o-transform: translate(242.5px, 242.5px);
transform: translate(242.5px, 242.5px);
}
.tile-container .tile-pos-2-3 {
-webkit-transform: translate(242.5px, 363.75px);
-ms-transform: translate(242.5px, 363.75px);
-o-transform: translate(242.5px, 363.75px);
transform: translate(242.5px, 363.75px);
}
.tile-container .tile-pos-3-0 {
-webkit-transform: translate(363.75px, 0);
-ms-transform: translate(363.75px, 0);
-o-transform: translate(363.75px, 0);
transform: translate(363.75px, 0);
}
.tile-container .tile-pos-3-1 {
-webkit-transform: translate(363.75px, 121.25px);
-ms-transform: translate(363.75px, 121.25px);
-o-transform: translate(363.75px, 121.25px);
transform: translate(363.75px, 121.25px);
}
.tile-container .tile-pos-3-2 {
-webkit-transform: translate(363.75px, 242.5px);
-ms-transform: translate(363.75px, 242.5px);
-o-transform: translate(363.75px, 242.5px);
transform: translate(363.75px, 242.5px);
}
.tile-container .tile-pos-3-3 {
-webkit-transform: translate(363.75px, 363.75px);
-ms-transform: translate(363.75px, 363.75px);
-o-transform: translate(363.75px, 363.75px);
transform: translate(363.75px, 363.75px);
}
@media screen and (max-width: 525px) {
.container {
width: 280px;
height: 405px;
}
.header {
height: 110px;
margin-bottom: 15px;
}
.game-info {
height: 40px;
}
.game-title {
font-size: 50px;
}
.game-container {
width: 280px;
height: 280px;
padding: 7px;
}
.gird-container {
width: 266px;
height: 266px;
}
.gird-row {
width: 266px;
height: 61.25px;
margin-bottom: 7px;
}
.gird-col {
width: 61.25px;
height: 61.25px;
margin-right: 7px;
}
.tile-container {
width: 266px;
height: 266px;
top: 7px;
}
.game-over:after {
font-size: 40px;
height: 70px;
}
.game-win:after {
font-size: 45px;
height: 60px;
}
.game-win-again {
width: 130px;
height: 40px;
bottom: 60px;
font-size: 25px;
}
.game-win-again:after {
content: "Continue";
}
.tile {
width: 61.25px;
height: 61.25px;
line-height: 61.25px;
font-size: 35px;
}
.tile-container .tile-pos-0-1 {
-webkit-transform: translate(0, 68.25px);
-ms-transform: translate(0, 68.25px);
-o-transform: translate(0, 68.25px);
transform: translate(0, 68.25px);
}
.tile-container .tile-pos-0-2 {
-webkit-transform: translate(0, 136.5px);
-ms-transform: translate(0, 136.5px);
-o-transform: translate(0, 136.5px);
transform: translate(0, 136.5px);
}
.tile-container .tile-pos-0-3 {
-webkit-transform: translate(0, 204.75px);
-ms-transform: translate(0, 204.75px);
-o-transform: translate(0, 204.75px);
transform: translate(0, 204.75px);
}
.tile-container .tile-pos-1-0 {
-webkit-transform: translate(68.25px, 0);
-ms-transform: translate(68.25px, 0);
-o-transform: translate(68.25px, 0);
transform: translate(68.25px, 0);
}
.tile-container .tile-pos-1-1 {
-webkit-transform: translate(68.25px, 68.25px);
-ms-transform: translate(68.25px, 68.25px);
-o-transform: translate(68.25px, 68.25px);
transform: translate(68.25px, 68.25px);
}
.tile-container .tile-pos-1-2 {
-webkit-transform: translate(68.25px, 136.5px);
-ms-transform: translate(68.25px, 136.5px);
-o-transform: translate(68.25px, 136.5px);
transform: translate(68.25px, 136.5px);
}
.tile-container .tile-pos-1-3 {
-webkit-transform: translate(68.25px, 204.75px);
-ms-transform: translate(68.25px, 204.75px);
-o-transform: translate(68.25px, 204.75px);
transform: translate(68.25px, 204.75px);
}
.tile-container .tile-pos-2-0 {
-webkit-transform: translate(136.5px, 0);
-ms-transform: translate(136.5px, 0);
-o-transform: translate(136.5px, 0);
transform: translate(136.5px, 0);
}
.tile-container .tile-pos-2-1 {
-webkit-transform: translate(136.5px, 68.25px);
-ms-transform: translate(136.5px, 68.25px);
-o-transform: translate(136.5px, 68.25px);
transform: translate(136.5px, 68.25px);
}
.tile-container .tile-pos-2-2 {
-webkit-transform: translate(136.5px, 136.5px);
-ms-transform: translate(136.5px, 136.5px);
-o-transform: translate(136.5px, 136.5px);
transform: translate(136.5px, 136.5px);
}
.tile-container .tile-pos-2-3 {
-webkit-transform: translate(136.5px, 204.75px);
-ms-transform: translate(136.5px, 204.75px);
-o-transform: translate(136.5px, 204.75px);
transform: translate(136.5px, 204.75px);
}
.tile-container .tile-pos-3-0 {
-webkit-transform: translate(204.75px, 0);
-ms-transform: translate(204.75px, 0);
-o-transform: translate(204.75px, 0);
transform: translate(204.75px, 0);
}
.tile-container .tile-pos-3-1 {
-webkit-transform: translate(204.75px, 68.25px);
-ms-transform: translate(204.75px, 68.25px);
-o-transform: translate(204.75px, 68.25px);
transform: translate(204.75px, 68.25px);
}
.tile-container .tile-pos-3-2 {
-webkit-transform: translate(204.75px, 136.5px);
-ms-transform: translate(204.75px, 136.5px);
-o-transform: translate(204.75px, 136.5px);
transform: translate(204.75px, 136.5px);
}
.tile-container .tile-pos-3-3 {
-webkit-transform: translate(204.75px, 204.75px);
-ms-transform: translate(204.75px, 204.75px);
-o-transform: translate(204.75px, 204.75px);
transform: translate(204.75px, 204.75px);
}
}