console
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>随机数生成器</title>
<style>
body {
margin: 0;
padding: 0;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: #2c3e50;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
color: white;
user-select: none; /* 防止长按选中 */
-webkit-tap-highlight-color: transparent; /* 去除点击高亮 */
}
#number {
font-size: 150px;
font-weight: bold;
text-shadow: 2px 2px 10px rgba(0,0,0,0.3);
}
.hint {
margin-top: 20px;
font-size: 18px;
opacity: 0.6;
}
/* 点击时的动画效果 */
body:active {
background-color: #34495e;
}
</style>
</head>
<body onclick="generate()">
<div id="number">--</div>
<div class="hint">点击屏幕重新生成</div>
<script>
function generate() {
// 生成0到100的随机整数
const num = Math.floor(Math.random() * 101);
document.getElementById('number').innerText = num;
}
// 页面加载完成后立即生成一次
window.onload = generate;
</script>
</body>
</html>