当前位置: 首页 > article >正文

前端 : 用HTML ,CSS ,JS 做一个点名器

1.HTML:

<body>
		<div id = "content">
			<div id="top">
				<div id = "name">XAiot2302班点名器</div>
			</div>
			<div id = "center">
				<div id = "word">你准备好了吗?</div>
			</div>
			<div id = "bottom">
				<div id="btn_start">开始</div>
				<div id="btn_stop">停止</div>
				<div id = "btn_reset">重置</div>
			</div>
		</div>
	</body>

2.CSS     

<script src="jquery-3.6.0.js"></script>
		<style>
			*{
				margin: 0;
				padding: 0;
			}
			html,body{
				width:100%;
				height: 100%;
			}
			#content{
				width: 100%;
				height: 100%;
				position: relative;
			}
			#top{
				width:100%;
				height: 100px;
				/* background-color: aqua; */
				position: relative;	
			}
			#name{
				font-size: 50px;
				font-weight: 800;
				color:brown;
				position: absolute;
				top: 50%;
				margin-top: -25px;
				left: 40%;
				top: 100px;
			}
			#center{
				width:100%;
				height: 100px;
				/* background-color: blue; */
				position: relative;	
				top: 100px;	
			}
			#word{
				font-size: 40px;
				color: red;
				position: absolute;
				top: 50%;
				margin-top: -25px;
				left: 50%;
				margin-left: -50px;
			}
			#bottom{
				width:100%;
				height: 400px;
				/* background-color: blue; */
				position: relative;	
				top: 130px;	
			}
			#btn_start{
				font-size: 40px;
				color: white;
				position: absolute;
				top: 20%;
				margin-top: -20px;
				left: 50%;
				background-color: red;
				border-radius: 10px;
			}
			#btn_stop{
				font-size: 40px;
				color: white;
				position: absolute;
				top: 40%;
				margin-top: -20px;
				left: 50%;
				background-color: yellow;
				border-radius: 10px;
			}
			#btn_reset{
				font-size: 40px;
				color: white;
				position: absolute;
				top: 60%;
				margin-top: -20px;
				left: 50%;
				background-color: skyblue;
				border-radius: 10px;
			}
		</style>

    3.JS

<script type="text/javascript">
	var nums=["乔凯晨","张晋若","张立","焦鹏祥","郭鑫","景清雷","徐绍平","代卫能","曹科","郭力玮","张彪","刘卓锦"];
	function suiji(){
		var num = Math.random()*nums.length;
		var num = Math.floor(num);
		var i = nums[num];
		$("#word").html(i);
	}
	var id = 0;
	$("#btn_start").click(function()
	{
		id = setInterval(suiji,80);
	});
	$("#btn_stop").click(function()
	{
		clearInterval(id);
	});
	$("#btn_reset").click(function()
	{
		// location.reload();
		$("#btn_start").html("开始");
		$("#word").html("你准备好了吗?")
	});
</script>

效果展示:


http://www.kler.cn/news/108100.html

相关文章:

  • 【知识串联】概率论中的值和量(随机变量/数字特征/参数估计)【考研向】【按概率论学习章节总结】(最大似然估计量和最大似然估计值的区别)
  • C++之左值、右值、std::forward、std::move总结(二百五十)
  • 多线程---wait和notify
  • 闭包和函数柯里化的理解
  • 测开 (Junit 单元测试框架)
  • 【C++】模版进阶
  • UE4/UE5 设置widget中text的字体Outline
  • docker 中给命令起别名
  • pytorch 笔记:index_select
  • Java面试八股文之暑假合集
  • Seata入门系列【15】@GlobalLock注解使用场景及源码分析
  • 面试经典150题——Day24
  • React Router初学者入门指南(2023版)
  • Pytorch代码入门学习之分类任务(三):定义损失函数与优化器
  • 【Qt】绘图与绘图设备
  • C++不能在子类中构造函数的初始化成员列表中直接初始化基类成员变量
  • C++ 运算符
  • Linux touch命令:创建文件及修改文件时间
  • 底层驱动day8作业
  • 【C++】智能指针:auto_ptr、unique_ptr、share_ptr、weak_ptr(技术介绍 + 代码实现)(待更新)
  • Megatron-LM GPT 源码分析(三) Pipeline Parallel分析
  • AWS SAP-C02教程11-解决方案
  • C#,数值计算——分类与推理,基座向量机的 Svmgenkernel的计算方法与源程序
  • 中微爱芯74逻辑兼容替代TI/ON/NXP工规品质型号全
  • 【杂记】Ubuntu20.04装系统,安装CUDA等
  • python爬虫之feapder.AirSpider轻量爬虫案例:豆瓣
  • PHP简单实现预定义钩子和自定义钩子
  • Linux国产系统无法连接身份证读卡器USB权限解决办法
  • nrf52832 开发板入手笔记:J-Flash 蓝牙协议栈烧写
  • Nginx 的配置文件(负载均衡,反向代理)