-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1.html
116 lines (107 loc) · 3.79 KB
/
1.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Some page</title>
<style>
/* 文本样式 */
/* 背景 */
body {
background: linear-gradient(to bottom, #F2F8FF, #D8FFFB);
margin: 0;
height: 100vh;
}
/* 文本 */
p {
font-size: 16px;
line-height: 1.6;
background-color: rgba(255, 255, 255, 0.5);
padding: 0px;
color: #353A49;
}
/* 比较大的字 */
h1 {
color: #44CEF4;
text-align: center;
background-color: rgba(255, 255, 255, 0.5);
padding: 0px;
}
/* 链接样式 */
/* 链接 */
a.custom-link {
display: inline-block;
background-color: #000000;
color: white;
padding: 10px 20px;
text-decoration: none;
font-size: 16px;
}
/* 点击链接的时候 */
a.custom-link:hover {
background-color: #D8FFFB;
}
/* 脚本样式 */
/* 。。。 */
#game-container {
display: none; /* 初始隐藏游戏 */
text-align: left;
}
/* 输入框 */
#game-container input {
padding: 10px;
font-size: 16px;
}
</style>
</head>
<body>
<h1>Welcome to Dvclv</h1>
<p>There is nothing but something.</p>
<div style="display: grid;">
<a href="https://space.bilibili.com/411282991?spm_id_from=333.976.0.0" class="custom-link">磁砖的b站主页</a>
<a href="https://author.baidu.com/home?context={%22from%22:%22personal-center%22,%22uk%22:%22tNUm-pkW_SQYEaYIKK2wsg%22,%22tab%22:%22dynamic%22}" class="custom-link">磁砖的百度主页</a>
</div>
<p id="trigger">这里有一个好东西awa</p>
<div id="game-container">
<h1>猜数字游戏</h1>
<p>范围:1~100</p>
<input type="number" id="guess" placeholder="写在这里" onkeypress="return event.keyCode != 13">
<p id="result"></p>
</div>
<script>
/* 脚本 */
var secretNumber = Math.floor(Math.random() * 100) + 1;
var attempts = 0;
function checkGuess() {
var userGuess = document.getElementById("guess").value;
// 检查输入是否为数字
if (isNaN(userGuess) || userGuess.trim() === '') {
document.getElementById("result").innerHTML = "呃。。。";
return; // 如果不是数字,则不进行后续操作并退出函数
}
// 将输入转换为数字
userGuess = Number(userGuess);
attempts++;
if (userGuess == secretNumber) {
document.getElementById("result").innerHTML = "尝试了 " + attempts + " 次之后,你猜到了" + secretNumber + "。";
} else if (userGuess < secretNumber) {
document.getElementById("result").innerHTML = userGuess + " 太低了。继续。";
} else if (userGuess > secretNumber) {
document.getElementById("result").innerHTML = userGuess + " 太高了。继续。";
}
document.getElementById("guess").value = ""; // 清空输入框
}
// 添加事件监听器,监听回车键
document.getElementById('guess').addEventListener('keypress', function(event) {
if (event.keyCode === 13) { // 回车键的键码是13
event.preventDefault(); // 阻止默认行为
checkGuess();
}
});
// 点击触发显示游戏
document.getElementById('trigger').addEventListener('click', function() {
document.getElementById('game-container').style.display = 'block';
});
</script>
</body>
</html>