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>

相关推荐

  1. 如何理解HTML网页结构?

    2024-04-21 15:14:03       72 阅读
  2. 【leetcode】点名

    2024-04-21 15:14:03       37 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-21 15:14:03       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-21 15:14:03       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-21 15:14:03       87 阅读
  4. Python语言-面向对象

    2024-04-21 15:14:03       96 阅读

热门阅读

  1. 概念Android AMS

    2024-04-21 15:14:03       35 阅读
  2. 洛谷 P2279 [HNOI2003] 消防局的设立

    2024-04-21 15:14:03       37 阅读
  3. 树莓派的应用场景都有哪些?

    2024-04-21 15:14:03       39 阅读
  4. css 中backdrop-filter使用

    2024-04-21 15:14:03       36 阅读
  5. pytorch中unsqueeze用法说明

    2024-04-21 15:14:03       37 阅读
  6. esp32s3中使用双通道通信解决TCP粘包问题

    2024-04-21 15:14:03       29 阅读
  7. 【Unity】Unity项目启动时报找不到Git

    2024-04-21 15:14:03       38 阅读
  8. 速盾:cdn可以加速哪些服务器

    2024-04-21 15:14:03       41 阅读
  9. 富格林:学习安全技能阻挠诱导虚假

    2024-04-21 15:14:03       36 阅读
  10. 【pytorch】内容链接汇总

    2024-04-21 15:14:03       39 阅读
  11. 浏览器原理 之 浏览器安全

    2024-04-21 15:14:03       41 阅读