feat: add initial template

This commit is contained in:
sangge 2023-10-29 12:34:50 +08:00
parent 2cd3f14fe7
commit 52473f1bfe
3 changed files with 96 additions and 0 deletions

23
index.html Normal file
View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>饭堂界面</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="canteen">
<img src="background.png" class="background" alt="Background">
<img src="desktop.png" class="table" alt="Table">
<img src="dinner_plate.png" class="plate" alt="Plate">
<img src="chef_hand.png" class="chef-hand" alt="Chef's Hand">
<img src="rice.png" class="rice" alt="Rice">
<img src="braised_pork.png" class="meat" alt="Meat">
</div>
<button onclick="serveFood()">Serve Food</button>
<script src="script.js"></script>
</body>
</html>

24
script.js Normal file
View File

@ -0,0 +1,24 @@
let step = 0;
function serveFood() {
switch(step) {
case 0:
document.querySelector('.chef-hand').style.opacity = '1';
setTimeout(() => {
document.querySelector('.rice').style.opacity = '1';
document.querySelector('.chef-hand').style.opacity = '0';
}, 500);
break;
case 1:
document.querySelector('.chef-hand').style.opacity = '1';
setTimeout(() => {
document.querySelector('.meat').style.opacity = '1';
document.querySelector('.chef-hand').style.opacity = '0';
}, 500);
break;
default:
step = -1;
break;
}
step++;
}

49
styles.css Normal file
View File

@ -0,0 +1,49 @@
.canteen {
position: relative;
width: 500px;
height: 500px;
margin: 50px auto;
}
.table {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.plate {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1;
}
.chef-hand {
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
opacity: 0;
transition: opacity 0.5s;
z-index: 3;
}
.rice, .meat {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
opacity: 0;
transition: opacity 0.5s;
z-index: 2;
}
button {
display: block;
margin: 20px auto;
padding: 10px 20px;
font-size: 18px;
}