Create and click on 9 image holes, keep score and time limit
HTML
<h1>🃏 Robotime Memory Match</h1>
<div id="timer">Starting in 3</div>
<div id="game"></div>
<div id="message"></div>
CSS
body{
font-family:Arial;
background:#f5f5f5;
text-align:center;
margin:0;
padding:20px;
}
#timer{
font-size:24px;
font-weight:bold;
margin-bottom:20px;
}
#game{
width:500px;
margin:auto;
display:grid;
grid-template-columns:repeat(4,110px);
gap:10px;
justify-content:center;
}
.card{
width:110px;
height:110px;
background:#444;
border-radius:10px;
cursor:pointer;
overflow:hidden;
display:flex;
align-items:center;
justify-content:center;
transition:0.3s;
}
.card img{
width:100px;
height:100px;
object-fit:cover;
border-radius:8px;
opacity:0;
transition:0.3s;
}
.card.flipped img,
.card.matched img{
opacity:1;
}
.card.matched{
background:#8fd18f;
cursor:default;
}
#message{
margin-top:20px;
font-size:28px;
color:green;
font-weight:bold;
}
JavaScript
const game =
document.getElementById("game");
const message =
document.getElementById("message");
const timerText =
document.getElementById("timer");
let startTime;
let timerInterval;
/* 321倒计时 */
let countdown = 3;
const countdownInterval =
setInterval(()=>{
countdown--;
if(countdown > 0){
timerText.innerHTML =
"Starting in " + countdown;
}else{
clearInterval(
countdownInterval);
startGame();
}
},1000);
/* 图片 */
const images =...