文件下载进度条演示

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文件下载进度条演示</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 600px;
            margin: 0 auto;
            padding: 20px;
            text-align: center;
        }
        .progress-container {
            width: 100%;
            background-color: #f1f1f1;
            border-radius: 5px;
            margin: 20px 0;
        }
        .progress-bar {
            height: 30px;
            background-color: #4CAF50;
            border-radius: 5px;
            width: 0%;
            transition: width 0.3s;
            text-align: center;
            line-height: 30px;
            color: white;
        }
        button {
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
        }
        button:hover {
            background-color: #45a049;
        }
        .info {
            margin-top: 20px;
            font-size: 14px;
            color: #666;
        }
    </style>
</head>
<body>
    <h1>文件下载进度演示</h1>
    <p>点击下方按钮模拟文件下载过程</p>
    
    <button id="downloadBtn">开始下载</button>
    
    <div class="progress-container">
        <div id="progressBar" class="progress-bar">0%</div>
    </div>
    
    <div id="status"></div>
    
    <div class="info">
    </div>

    <script>
        document.getElementById('downloadBtn').addEventListener('click', function() {
            const progressBar = document.getElementById('progressBar');
            const statusDiv = document.getElementById('status');
            
            // 重置进度条
            progressBar.style.width = '0%';
            progressBar.textContent = '0%';
            statusDiv.textContent = '准备下载...';
            
            // 模拟下载过程
            let progress = 0;
            const interval = setInterval(function() {
                progress += Math.random() * 10;
                if (progress >= 100) {
                    progress = 100;
                    clearInterval(interval);
                    statusDiv.textContent = '下载完成!';
                    
                    // 下载完成后显示链接
                    statusDiv.innerHTML += '<br>感谢使用我们的服务';
                }
                
                progressBar.style.width = progress + '%';
                progressBar.textContent = Math.floor(progress) + '%';
                statusDiv.textContent = '下载中: ' + Math.floor(progress) + '%';
            }, 300);
        });
    </script>
</body>
</html>

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值