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>
运行代码
查看全文
相关阅读:
分页
uuid算法
mysql卸载安装
安装和破解收费版idea
css样式一开始不显示,点击显示隐藏
各种技术网址
vue加载高德地图,加标记点,点出文本框
Security Traps 玩耍剧透(持续更新)
最近做的一个小玩意踩的坑
最近刷题的一个总结
原文地址:https://www.cnblogs.com/jikey/p/2736599.html
最新文章
B树,B+树,B*树
平衡二叉树
两个,当时用的那个不记得了
ubuntu 16.04 mysql5.7.17 开放远程3306端口
linux 下安装mysql
linux 下安装tomcat
linux 获取帮助的命令
TestNG
jdbc链接数据库
金融类产品面试题目以及场景人力面试题目整理
热门文章
Centos6.5安装配置svn服务器
Iptables防火墙规则使用详解
Linux iptables 防火墙常用规则
CentOS 7中firewall防火墙详解和配置以及切换为iptables防火墙
centos6安装mysql 5.6.33
DDOS攻击
OSI七层模型与TCP/IP五层模型
TCP中SYN洪水攻击
常见的几种弱网测试
md5加密
Copyright © 2011-2022 走看看