<!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>Document</title>
<link rel="stylesheet" href="./css/css.css">
</head>
<body>
<div class="container">
<div class="title">
鄱阳湖点名册
</div>
<div class="select">
<div class="select_list">
<div class="list_title">
点名次数
</div>
<div class="list_num">
<span>
1
</span>
</div>
</div>
<div class="select_list">
<div class="list_title">
点名人数
</div>
<div class="list_num">
<select class="select_value">
<option value="1">1</option>
</select>
</div>
</div>
</div>
<div class="select_active">
</div>
<div class="select_active select_wei">
</div>
<div class="btn">
<button class="start">开始</button>
<button class="record">记录</button>
</div>
</div>
</body>
<script src="./js/stu.js"></script>
<script src="./js/rool.js"></script>
</html>
*{
margin: 0;
padding: 0;
}
body{
width: 100vw;
height: 100vh;
background: url(../images/bj.jpg);
background-repeat: no-repeat;
background-size: 100% 100%;
color: rgb(34, 50, 73);
}
.title{
text-align: center;
height: 80px;
line-height: 80px;
font-size: 35px;
font-weight: bold;
font-family: '宋体';
}
.select{
width: 40%;
margin-left: 30%;
display: flex;
}
.select .select_list{
width: 50%;
text-align: center;
line-height: 35px;
}
.select .select_list span{
width: 40px;
height: 22px;
line-height: 22px;
border-radius: 3px;
border: 1px solid rgba(255, 255, 255, 0.661);
display: inline-block;
background-color: rgb(255, 192, 203);
}
.select_value{
width: 40px;
height: 22px;
line-height: 22px;
border-radius: 3px;
border: 1px solid rgba(255, 255, 255, 0.661);
display: inline-block;
background-color: rgb(255, 192, 203);
outline: none;
}
.select_active{
width: 1160px;
min-height: 80px;
padding: 20px;
background-color: rgb(255, 255, 255,0.9);
border-radius: 9px;
margin-top: 25px;
transform: translateX(calc((100vw - 1200px)/2));
}
.select_active span{
width: 70px;
height: 70px;
line-height: 70px;
text-align: center;
border-radius: 50%;
display: inline-block;
margin-bottom: 10px;
margin-left: 10px;
color: rgb(255, 255, 255)
}
.select_active .boy{
background-color: rgb(121, 164, 194);
}
.select_active .girl{
color: black;
background-color: pink;
color: rgb(255, 255, 255)
}
button{
width: 50px;
height: 50px;
border-radius: 50%;
font-size: 16px;
color: #fff;
background-color:rgb(49, 69, 86);
outline: none;
border: 0;
position: fixed;
right: 20px;
bottom: 8%;
}
.start{
bottom: 17%;
}
button:active{
background-color: rgb(33, 47, 59);
}
.active{
color: #fff !important;
background-color: rgb(143, 203, 90) !important;
}
let select_wei = document.querySelector('.select_wei');
let select_active = document.querySelector('.select_active')
let start = document.querySelector('.start');
let select_set = null;
let arr_stu = [];
let set_stu = null;
start.onclick = function (){
clearInterval(set_stu);
clearInterval(select_set);
select_active.innerHTML = '';
if(start.innerText == '开始'){
start.innerText = '停止';
set_student();
}else{
start.innerText = '开始';
stop_stu()
}
}
wei_stu(arr);
function wei_stu(array){
select_wei.innerHTML = '';
array = arr_luan(array);
for(var i in array){
create_span(array[i])
}
}
function set_student(){
set_stu = setInterval(function (){
wei_stu(arr)
},100)
}
function stop_stu(){
clearInterval(set_stu);
select_student()
}
function select_student(){
let span_arr = select_wei.querySelectorAll('span');
console.log(span_arr);
arr_stu = [];
select_set = setInterval(function (){
let select_value = document.querySelector('.select_value').value;
let num = Math.floor(Math.random()* arr.length);
if(arr_stu.indexOf(span_arr[num].innerText) == -1){
arr_stu.push(span_arr[num].innerText);
let obj = {
name:span_arr[num].innerText,
sex:span_arr[num].className == 'boy' ? '男' : '女'
}
create_span(obj,1);
span_arr[num].classList.add('active');
}
if(arr_stu.length == select_value){
clearInterval(select_set)
}
},200)
}
function create_span(obj,type){
let span = document.createElement('span');
obj.sex == '男' ? span.className = 'boy' :span.className = 'girl';
span.innerText = obj.name;
if(type == 1){
select_active.appendChild(span);
}else{
select_wei.appendChild(span);
}
}
function arr_luan(array){
let arr = JSON.parse(JSON.stringify(array));
let newArr = [];
for(let i in array){
let num = Math.floor(Math.random() * arr.length);
newArr.push(arr[num]);
arr.splice(num,1);
}
return newArr;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~