zoukankan
html css js c++ java
数字倒数效果
当页面初步加载时,显示数字滚动。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> <title>test</title> <style type="text/css"> *{ margin:0; padding:0;} body{font:12px/1 arial; background:#3f3f3f;} .num{ 500px; padding:10px 0;border-radius:15px;text-shadow:1px 1px 1px #999; color:#fff;text-align:center; margin:120px auto; font-size:62px; font-weight:bold; border:5px solid #ccc; background:#fff;} .num strong{ font-weight:normal; border:1px solid #ccc; background:#333; padding:0 10px; text-align:center;} </style> </head> <body> <div id="num" class="num" style="display:none;">1000000</div> <script type="text/javascript"> String.prototype.repeat = function(n){ return Array(n + 1).join(this); }; var addFixed = 5, // 单次增加值 node = document.getElementById('num'), emTotal = node && node.innerHTML; function numAnim(){ var len = 1, last = 0, // 最终值 n = 0; // 需要填充的空白0 if(addFixed < emTotal){ // 跳出setTimeout条件 addFixed += Math.ceil((emTotal - addFixed) / 3); len = emTotal.length - (addFixed + '').length; last = n + '' + addFixed; n = '0'.repeat(10).slice(len); if(len == 0){ // 如果等于0后删除首位 last = last.slice(1); } last = last.split(''); last = '<strong>' + last.join('</strong><strong>') + '</strong>'; node.innerHTML = last; } setTimeout(numAnim, 100); } node.style.display = 'block'; numAnim(); </script> </body> </html>
运行代码
查看全文
相关阅读:
Python 如何隐藏属性
Python 多态
Python 绑定方法与非绑定方法
Python 类的组合
ASP.NET CS文件中输出JavaScript脚本的3种方法以及区别
JQuery中$之选择器用法介绍
C#语言之“string格式的日期时间字符串转为DateTime类型”的方法
.net中response.redirect sever.execute server.transfer 三种页面跳转的方法
safari,chrome中的window.history.go(-1) history.back()
onbeforeunload与onunload事件
原文地址:https://www.cnblogs.com/jikey/p/2736599.html
最新文章
hdu多校第一场 1013(hdu6590)Code 凸包交
hdu多校第一场1003 (hdu6580)Milk 背包
hdu多校第一场 1006 (hdu6583)Typewriter dp/后缀自动机
hdu多校第一场1005(hdu6582)Path 最短路/网络流
POJ_3696 The Luckiest number 【欧拉定理+同余式+对取模的理解】
POJ_3090 Visible Lattice Points 【欧拉函数 + 递推】
POJ_2478 Farey Sequence 【欧拉函数+简单递推】
POJ_1284 Primitive Roots 【原根性质+欧拉函数运用】
POJ_2407 Relatives 【欧拉函数裸题】
欧拉函数【学习笔记】
热门文章
Pollard_Rho 整数分解法【学习笔记】
整数分解普通分法【学习笔记】
Miller_Rabin素数测试【学习笔记】
HDU_1846 Brave Game 【巴什博弈】
Python 析构函数__del__
Python __str__用法
Python item的使用
Python 反射
Python 静态属性Property
Python 封装
Copyright © 2011-2022 走看看