HTML下的点名

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title></title>

<style>

*{

margin-left: 0px;

margin-top: 0px;

}

.container{

background-image: url(https://img.zcool.cn/community/01deac5b71220fa801206a3594899b.jpg@1280w_1l_2o_100sh.jpg);

background-color: aqua;

width: 1000px;

height: 480px;

border: 1px solid rgb(0, 255, 157);

position:absolute;

left: 50%;

margin-left: -500px;

text-align: center;

line-height: 100px;

margin-top: 150px;

}

.box,.box2{

width: 300px;

height: 300px;

background-image: url(https://img.chuapp.com/wp-content/uploads/2016/08/201608231471931218.gif?imageView2/2/w/700);

border-radius: 50%;

/* 水平位置居中 */

margin: auto;

margin-top: 50px;

text-align: center;

line-height: 300px

}

.box2{

background-color: blue;

}

#show{

font-size: 30px;

color: rgb(12, 14, 1);

font-weight: bolder;

}

#start{

width: 300px;

height: 50px;

background-color: rgb(0, 255, 170);

}

</style>

</head>

<body>

<div class="container">

<div class="box" id="box">

<span id="show">就决定是你了</span>

</div>

<button id="start" οnclick="change()">点名</button>

</div>

</body>

</html>

<script>

var flag = false

var awards = ["张三","李四","王二狗","小黄毛","绿茶","细狗","周扒皮","狗剩"]

var box = document.getElementById("box")

var show = document.getElementById("show")

var start = document.getElementById("start")

var timer

function change(){

if(!flag) {

flag = true

start.innerHTML="停止"

timer = setInterval(function(){

let index = Math.floor(Math.random()*awards.length)

show.innerHTML = awards[index]

box.setAttribute("class","box")

},10)

}else{

flag = false

start.innerHTML= "点名"

clearInterval(timer)

box.setAttribute("class","box")

}

}

</script>

相关推荐
Bigger2 分钟前
第八章:我是如何剖析 Claude Code 里的“电子宠物”彩蛋的
前端·ai编程·源码阅读
qq_3643717215 分钟前
NestJS + LangChain SSE 流式输出 + 前端实时渲染打字机效果
前端·langchain
1314lay_100717 分钟前
axios的Post方法和Delete方法的参数个数和位置不同,导致415错误
前端·javascript·vue.js·elementui
LXXgalaxy24 分钟前
HTML头部元信息避坑指南
前端·html
qq_3813385025 分钟前
现代 CSS 黑科技:Container Queries、:has() 与嵌套语法实战
前端·css·科技
枫叶丹426 分钟前
【HarmonyOS 6.0】ArkWeb:Web组件销毁模式深度解析
开发语言·前端·华为·harmonyos
拉拉尼亚27 分钟前
WebRTC 完全指南:原理、教程与应用场景
前端·typescript·实时音视频
lkbhua莱克瓦2429 分钟前
ZogginWeb 电脑端沉浸式记单词整合优化方案(终极版)
前端·zogginweb开发
小则又沐风a30 分钟前
深剖string内部结构 手撕string
java·前端·数据库·c++
不恋水的雨32 分钟前
html中补齐table表格合并导致每行td数量不一致的情况
前端·html