JS实现网页进度条

1.在网页上设置一个Download按钮,对其进行样式改造,这里我使用margin-left和margin-top来设置button在网页中呈现的位置。

2.在js中改变进度条div的style中的width。当定时器每10ms刷新一次时,进度条中会有数值变化,而这个就是div.innerText,没刷新一次count++,也就是我们看见的1%、2%、3%......而进度条的div.style.width的值是呈2*count增加的,这就是进度条,而在div的css中已经将div的background-color设置成了蓝色了

3.给button设置一个onclick,当点击按钮时开始进度条的加载显示

代码实现:

<!DOCTYPE html>
<html>
 
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#div1 {
				width: 0px;
				height: 25px;
				background-color: blue;
				text-align: center;
				margin-left: 10.6cm;
				margin-top: 2cm;
			}

			#button {
				width: 100px;
				height: 20px;
				background-color: 	#C0C0C0;
				text-align: center;
				margin-left: 16cm;
				margin-top: 5cm;
			}
		</style>
	</head>
 
	<body>
		<button onclick&
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值