1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
| <!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>随机点名</title> <style> * { padding: 0; margin: 0; background-color: #414141; } div { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; } span, h2 { text-shadow: 0 0 10px #dfd8d8; background: linear-gradient(135deg, #14ffe9, #ffeb3b, #ff00e0); -webkit-background-clip: text; -webkit-text-fill-color: transparent; animation: ff 0.9s linear infinite; } @keyframes ff { to { filter: hue-rotate(360deg); } } h2 { font-size: 72px; } span { font-size: 46px; } button { position: absolute; top: 70%; left: 50%; transform: translate(-50%, -50%); width: 80px; height: 25px; box-shadow: 0 0 10px #fff; outline: none; background-color: gray; } </style> </head>
<body> <div> <h2>随机点名</h2> <span id="name"></span> </div> <button id="button_text">stop</button>
<script>
let nametxt = document.getElementById('name'); let button = document.getElementById('button_text');
let uname = ['小', '幻', '郑', '朕', '晓', '萧', '双', '梦', '霜', '影', '逐', '千', '城', '仞', '春', '夏', '雪', '秋', '冬', '的', '少', '年', '从', '前', '希', '欢', '喜', '天', '回', '清', '下', '白', '月', '暗', '光' ];
function getrandom(min, max) { return Math.floor(Math.random() * (max - min - 1) + min); }
function clock() {
let random = uname[getrandom(0, uname.length - 1)];
nametxt.innerHTML = random; };
let time = self.setInterval("clock()", 100);
let flag = false; button.onclick = function() {
if (flag == false) { time = window.clearInterval(time);
button.innerHTML = 'start';
flag = true; } else {
time = self.setInterval("clock()", 100); button.innerHTML = 'stop'; flag = false; } } </script> </body>
</html>
|