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

前端 : 用html ,css,js写一个你画我猜的游戏

1.HTML:

<body><div id = "content"><div id = "box1">计时器</div><div id="box"><div id= "top"><div id = "box-top-left">第几题:</div><div id = "box-top-right">得分:</div></div><div id = "center"><div id = "youxi">你画我猜</div><div id="timu">1234</div><div id="btn-start">开始游戏</div></div><div id = "bottom"><div id = "right">对</div><div id = "wrong">错</div></div></div></div></body>

2.CSS:
 

<style type="text/css">*{margin: 0;padding: 0;}html,body{width: 100%;height: 100%;}#content{width:100%;height:100%;/* background-color: blue; */min-width: 1040px;min-height: 800px;position: relative;}#box1{width: 30%;height: 100%;position: relative;font-size: 50px;color: red;text-align: center;}#box{width:80%;height: 100%;/* background-color: aqua; */position: absolute;top: 0;right: 0;}#top{width: 80%;height: 60px;/* background-color: black; */position: relative;top: 20px;right: -150px;}#box-top-left{font-size: 40px;font-weight: 600;font-family: 楷体;margin-left: 50px;margin-top: 30px;color: gray;display: inline-block;}#box-top-right{font-size: 40px;font-weight: 600;font-family: 楷体;display: inline-block;margin-left: 600px;margin-top: 30px;color: gray;}#center{width: 80%;height: 400px;/* background-color: red; */position: relative;top: 100px;right: -150px;}#youxi{width: 100%;height: 100px;text-align: center;margin: 0 auto;font-weight: 700;font-family: 宋体;font-size: 70px;position: absolute;top: 100px;}#btn-start{width: 50%;height: 40px;text-align: center;color: crimson;margin: 0 auto;font-size: 30px;position: absolute;top: 300px;right: 250px;background-color: white;font-weight: 600;}#bottom{width:80% ;height: 100px;/* background-color: aqua; */position: relative;top: 200px;right: -150px;}#right{width:30% ;height: 40px;position: absolute;top:10%;left: 100px;font-size: 50px;}#wrong{position: absolute;right:100px;top: 10%;font-size: 50px;}</style>

3.JS代码:

<script type="text/javascript">var nums =0;var scores = 1;var yes = document.getElementById("right");var no = document.getElementById("wrong");var btnstart = document.getElementById("btn-start");var bod = document.getElementById("timu");var boxl  = document.getElementById("box-top-left");var boxr  = document.getElementById("box-top-right");var boxt  = document.getElementById("box1");var str01 = ["伊泽瑞尔","放逐之刃","无双剑姬","暗黑元首","逆羽","幻翎","暗裔剑魔","锤石","泰坦","德玛西亚之力","德玛西亚皇子","青钢影","诺克萨斯之手","艾瑞利亚"];btnstart.onclick=function(){nums =0;scores = 1;suiji();var num = 180;var id = setInterval(function(){num--;if(num<0){clearInterval(id);}else{boxt.innerHTML = num;}},1000);}function suiji(){var num = Math.floor(Math.random()*14);bod.innerHTML = str01[num];}yes.onclick = function(){suiji();nums++;scores++;boxl.innerHTML = "第" + nums + "题";boxr.innerHTML = "得分:"+ scores;}no.onclick = function(){suiji();nums++;boxl.innerHTML = "第" + nums + "题";}</script>

效果展示:

http://www.lryc.cn/news/210525.html

相关文章:

  • Illustrator 2024(AI v28.0)
  • 【Git企业开发】第二节.Git 的分支管理
  • 第三章认识Node.js模块化开发
  • 扩展Nginx的无限可能:掌握常见扩展模块和第三方插件的使用方法
  • centos遇到的问题
  • 本机spark 通idea连接Oracle的坑
  • 网络协议--DNS:域名系统
  • 计算机视觉注意力机制小盘一波 (学习笔记)
  • LVS+keepalive高可用集群
  • Thread 和 Runnable 的区别
  • 图神经网络和分子表征:5. Completeness
  • css-渐变色矩形
  • 使用easypoi-spring-boot-starter 4.1.1导入excel报错NoSuchMethodError和NoSuchMethodError
  • matlab中类的分别之handle类和value类——matlab无法修改类属性值的可能原因
  • 3. t2t_vit inference
  • SpringMVC Day 05 : Spring 中的 Model
  • redis6.0源码分析:字典扩容与渐进式rehash
  • 【C++迭代器iterator】
  • 基于群居蜘蛛算法的无人机航迹规划
  • 火爆全网,Python+Requests+Pytest+YAML+Allure实现接口自动化测试(附源码)
  • 【深度学习】【NLP】如何得到一个分词器,如何训练自定义分词器:从基础到实践
  • 线程池的线程回收
  • 【2023.10.25练习】数据库-函数1
  • 基于水循环算法的无人机航迹规划-附代码
  • JVM调优(10)JVM的运行时数据区
  • Python网络爬虫介绍
  • iOS QR界面亮度调整
  • Linux shell编程学习笔记17:for循环语句
  • Go语言用Resty库编写的音频爬虫代码
  • AWTK 液体流动效果控件发布