Skip to content

Commit b7d5dd2

Browse files
made game more responsive on different devices
1 parent 0df6d05 commit b7d5dd2

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
</head>
1313
<body>
1414
<h1>Whack-a-mole! <span class="score">0</span></h1>
15-
<h2 class="timesUp"></h2>
15+
<h2 class="desc">Hit as many trolls as you can in 10s!</h2>
1616
<button onclick="startGame()">Start!</button>
17+
<h2 class="timesUp"></h2>
1718

1819
<div class="game">
1920
<div class="hole hole1">

style.css

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ body {
1616

1717
h1 {
1818
text-align: center;
19-
font-size: 10rem;
19+
font-size: calc(8vh + 1rem);
2020
line-height: 1;
2121
margin-bottom: 0;
2222
}
2323

2424
.score {
2525
background: rgba(255,255,255,0.2);
2626
padding: 0 3rem;
27-
line-height: 1;
27+
line-height: 2;
28+
font-size: calc(6vh + 1rem);
2829
border-radius: 1rem;
2930
}
3031

@@ -44,12 +45,13 @@ h1 {
4445

4546
.hole:after {
4647
display: block;
47-
background: url(dirt.svg) bottom center no-repeat;
48-
background-size: cover;
48+
background-image: url(dirt.svg);
49+
background-position: bottom center;
50+
background-repeat: no-repeat;
51+
background-size: contain;
4952
content: '';
5053
width: 100%;
51-
/* height: 70px; */
52-
height: 12vh;
54+
height: calc(6vh + 4rem);
5355
position: absolute;
5456
z-index: 2;
5557
bottom: -30px;
@@ -78,13 +80,19 @@ button, h2 {
7880
height: 30px;
7981
}
8082

83+
.desc {
84+
width: 400px;
85+
text-align: center;
86+
}
87+
8188
@media only screen and (max-width: 450px) {
8289
.game {
8390
width: 100vw;
8491
height: 40vh;
8592
margin: 0;
8693
}
8794
.hole:after {
88-
height: 8vh;
95+
height: calc(6vh + 1rem);
96+
background-position: center;
8997
}
9098
}

0 commit comments

Comments
 (0)