标签:weight var info splay code UNC width gray name
代码
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>倒计时</title> <style type="text/css"> * { margin: 0; padding: 0; } body { width: 100%; height: 100%; } #box { position: absolute; top: 50%; left: 50%; width: 600px; height: 100px; margin-top: -50px; margin-left: -300px; text-align: center; line-height: 100px; font-size: 26px; font-weight: 700; font-family: "黑体"; color: gray; } #box .seconds { display: inline-block; width: 50px; height: 50px; font-size: 48px; text-align: center; line-height: 50px; animation: animate 1s infinite; } @keyframes animate { from { font-size: 48px; } to { font-size: 24px; } } </style> <script type="text/javascript"> window.onload = function() { var box = document.getElementById("box"); var seconds = document.getElementsByClassName("seconds")[0]; seconds.innerText = "5"; var timer = setInterval(function() { seconds.innerText = parseInt(seconds.innerText) - 1; if (parseInt(seconds.innerText) < 0) { clearInterval(timer); box.innerHTML = "全军出击"; } }, 1000); } </script> </head> <body> <div id="box"> 敌军还有<i class="seconds"></i>秒到达战场... </div> </body> </html>
效果
标签:weight var info splay code UNC width gray name
原文地址:https://www.cnblogs.com/lightbc/p/12934262.html