网站首页 > 技术文章 正文
把代码复制在电脑文本文档中,文本文档后缀名改为html ,这样你就自己制作成功一个大乐透机选模拟器,来试试吧。
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D大乐透模拟器</title>
<style>
body {
font-family: 'Microsoft YaHei', sans-serif;
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
perspective: 1000px;
}
.container {
text-align: center;
}
h1 {
color: #e74c3c;
text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
margin-bottom: 30px;
}
.lottery-machine {
width: 300px;
height: 400px;
position: relative;
transform-style: preserve-3d;
animation: rotate 15s infinite linear;
margin: 0 auto 30px;
}
.machine-body {
position: absolute;
width: 100%;
height: 100%;
background: linear-gradient(145deg, #e74c3c, #c0392b);
border-radius: 20px;
box-shadow: 0 20px 40px rgba(0,0,0,0.3);
transform-style: preserve-3d;
}
.machine-top {
position: absolute;
width: 80%;
height: 15%;
background: #fff;
border-radius: 10px;
top: 10%;
left: 10%;
transform: translateZ(20px);
box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
}
.ball-display {
position: absolute;
width: 80%;
height: 50%;
background: rgba(255,255,255,0.9);
border-radius: 15px;
top: 30%;
left: 10%;
transform: translateZ(30px);
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
padding: 10px;
box-sizing: border-box;
box-shadow: inset 0 0 15px rgba(0,0,0,0.1);
}
.ball {
width: 40px;
height: 40px;
border-radius: 50%;
background: radial-gradient(circle at 30% 30%, #fff, #f1c40f);
display: flex;
justify-content: center;
align-items: center;
margin: 5px;
font-weight: bold;
color: #e74c3c;
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
transform-style: preserve-3d;
animation: ballFloat 3s infinite ease-in-out;
}
.ball:nth-child(2) {
animation-delay: 0.2s;
background: radial-gradient(circle at 30% 30%, #fff, #3498db);
}
.ball:nth-child(3) {
animation-delay: 0.4s;
background: radial-gradient(circle at 30% 30%, #fff, #2ecc71);
}
.ball:nth-child(4) {
animation-delay: 0.6s;
background: radial-gradient(circle at 30% 30%, #fff, #9b59b6);
}
.ball:nth-child(5) {
animation-delay: 0.8s;
background: radial-gradient(circle at 30% 30%, #fff, #e67e22);
}
.machine-bottom {
position: absolute;
width: 60%;
height: 10%;
background: #333;
border-radius: 5px;
bottom: 10%;
left: 20%;
transform: translateZ(15px);
}
.button {
position: absolute;
width: 60px;
height: 60px;
background: #f1c40f;
border-radius: 50%;
bottom: -30px;
left: 50%;
transform: translateX(-50%) translateZ(40px);
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
color: #c0392b;
box-shadow: 0 10px 20px rgba(0,0,0,0.2);
transition: all 0.3s;
}
.button:hover {
background: #f39c12;
transform: translateX(-50%) translateZ(40px) scale(1.1);
}
.button:active {
transform: translateX(-50%) translateZ(40px) scale(0.95);
}
@keyframes rotate {
0% { transform: rotateY(0deg); }
100% { transform: rotateY(360deg); }
}
@keyframes ballFloat {
0%, 100% { transform: translateY(0) translateZ(0); }
50% { transform: translateY(-10px) translateZ(10px); }
}
.result {
margin-top: 50px;
background: rgba(255,255,255,0.8);
padding: 20px;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
max-width: 500px;
}
.generated-numbers {
display: flex;
justify-content: center;
flex-wrap: wrap;
margin: 15px 0;
}
.result-ball {
width: 50px;
height: 50px;
border-radius: 50%;
background: #e74c3c;
color: white;
display: flex;
justify-content: center;
align-items: center;
margin: 5px;
font-weight: bold;
font-size: 20px;
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
.result-ball.blue {
background: #3498db;
}
</style>
</head>
<body>
<div class="container">
<h1>3D大乐透模拟器</h1>
<div class="lottery-machine">
<div class="machine-body">
<div class="machine-top"></div>
<div class="ball-display">
<div class="ball">?</div>
<div class="ball">?</div>
<div class="ball">?</div>
<div class="ball">?</div>
<div class="ball">?</div>
</div>
<div class="machine-bottom"></div>
<div class="button" onclick="generateNumbers()">抽奖</div>
</div>
</div>
<div class="result" id="result" style="display: none;">
<h2>本期开奖号码</h2>
<div class="generated-numbers" id="numbers"></div>
<p>祝您好运!下次开奖时间:<span id="next-draw"></span></p>
</div>
</div>
<script>
function generateNumbers() {
// 生成前区5个号码(1-35)
let frontNumbers = [];
while(frontNumbers.length < 5) {
let num = Math.floor(Math.random() * 35) + 1;
if(!frontNumbers.includes(num)) {
frontNumbers.push(num);
}
}
frontNumbers.sort((a, b) => a - b);
// 生成后区2个号码(1-12)
let backNumbers = [];
while(backNumbers.length < 2) {
let num = Math.floor(Math.random() * 12) + 1;
if(!backNumbers.includes(num)) {
backNumbers.push(num);
}
}
backNumbers.sort((a, b) => a - b);
// 显示结果
document.getElementById('result').style.display = 'block';
let numbersDiv = document.getElementById('numbers');
numbersDiv.innerHTML = '';
// 添加前区号码
frontNumbers.forEach(num => {
let ball = document.createElement('div');
ball.className = 'result-ball';
ball.textContent = num;
numbersDiv.appendChild(ball);
});
// 添加分隔符
let separator = document.createElement('div');
separator.style.display = 'flex';
separator.style.alignItems = 'center';
separator.innerHTML = '<span style="margin: 0 5px; font-size: 20px;">+</span>';
numbersDiv.appendChild(separator);
// 添加后区号码
backNumbers.forEach(num => {
let ball = document.createElement('div');
ball.className = 'result-ball blue';
ball.textContent = num;
numbersDiv.appendChild(ball);
});
// 设置下次开奖时间(假设是3天后)
let nextDraw = new Date();
nextDraw.setDate(nextDraw.getDate() + 3);
document.getElementById('next-draw').textContent = nextDraw.toLocaleDateString() + ' 20:00';
}
</script>
</body>
</html>
- 上一篇: 用这7个CSS技巧来解决跨浏览器和屏幕的兼容问题
- 下一篇: 求大佬帮我把这html的文档变成图片
猜你喜欢
- 2025-07-28 求大佬帮我把这html的文档变成图片
- 2025-07-28 用这7个CSS技巧来解决跨浏览器和屏幕的兼容问题
- 2025-07-28 在div中如何垂直对齐文本(div怎么垂直居中)
- 2025-07-28 有趣的css - 流光圆形按钮(css实现流光按钮效果)
- 2025-07-28 CSS入门指南:核心概念与实用技巧(css, the definitive guide)
- 2025-05-08 浅谈3种css技巧——两端对齐(css文字两端对齐属性)
- 2025-05-08 CSS 样式总翻车?5 个实战技巧让布局效率暴增 200%!
- 2025-05-08 CSS Flex 布局全攻略:从小白到精通
- 2025-05-08 CSS3 现代布局全攻略:Flexbox 终极指南
- 2025-05-08 网页世界隐藏的神秘代码语言,竟能这样改变布局
- 1518℃桌面软件开发新体验!用 Blazor Hybrid 打造简洁高效的视频处理工具
- 600℃Dify工具使用全场景:dify-sandbox沙盒的原理(源码篇·第2期)
- 521℃MySQL service启动脚本浅析(r12笔记第59天)
- 490℃服务器异常重启,导致mysql启动失败,问题解决过程记录
- 489℃启用MySQL查询缓存(mysql8.0查询缓存)
- 477℃「赵强老师」MySQL的闪回(赵强iso是哪个大学毕业的)
- 457℃mysql服务怎么启动和关闭?(mysql服务怎么启动和关闭)
- 454℃MySQL server PID file could not be found!失败
- 最近发表
- 标签列表
-
- cmd/c (90)
- c++中::是什么意思 (84)
- 标签用于 (71)
- 主键只能有一个吗 (77)
- c#console.writeline不显示 (95)
- pythoncase语句 (88)
- es6includes (74)
- sqlset (76)
- windowsscripthost (69)
- apt-getinstall-y (86)
- node_modules怎么生成 (76)
- c++int转char (75)
- static函数和普通函数 (76)
- el-date-picker开始日期早于结束日期 (70)
- js判断是否是json字符串 (67)
- checkout-b (67)
- c语言min函数头文件 (68)
- asynccallback (71)
- localstorage.removeitem (74)
- vector线程安全吗 (70)
- java (73)
- js数组插入 (83)
- mac安装java (72)
- 查看mysql是否启动 (70)
- 无效的列索引 (74)