当前位置: 首页 > news >正文

互联网广告行业seo最新快速排名

互联网广告行业,seo最新快速排名,wordpress php打包zip,做网站怎么选择服务器的大小如何实现一个基于 HTMLCSSJS 的任务进度条 在网页开发中,任务进度条是一种常见的 UI 组件,它可以直观地展示任务的完成情况。本文将向你展示如何使用 HTML CSS JavaScript 来创建一个简单的、交互式的任务进度条。用户可以通过点击进度条的任意位置来…

如何实现一个基于 HTML+CSS+JS 的任务进度条

在网页开发中,任务进度条是一种常见的 UI 组件,它可以直观地展示任务的完成情况。本文将向你展示如何使用 HTML + CSS + JavaScript 来创建一个简单的、交互式的任务进度条。用户可以通过点击进度条的任意位置来更新进度,并且进度条会同步显示百分比。

效果演示

用户点击进度条任意位置时,进度条会自动填充到该位置,进度百分比会动态显示在下方。
在这里插入图片描述

实现步骤

1. HTML 结构

首先,我们需要定义进度条的基本结构。进度条由一个容器元素 progress-bar 和一个表示进度的填充条 progress-fill 组成。还有一个 progress-text 元素用于显示当前的百分比。

<div class="progress-container"><div class="progress-bar" id="progressBar"><div class="progress-fill" id="progressFill"></div></div><div class="progress-text" id="progressText">进度: 0%</div>
</div>
2. CSS 样式

接下来,为进度条和百分比文字设置样式。我们使用 CSS 来设置进度条的尺寸、颜色和外观。

body {font-family: Arial, sans-serif;display: flex;justify-content: center;align-items: center;height: 100vh;margin: 0;
}.progress-container {width: 80%;max-width: 600px;
}.progress-bar {width: 100%;height: 30px;background-color: #e0e0e0;border-radius: 5px;position: relative;cursor: pointer;
}.progress-fill {width: 0;height: 100%;background-color: #4caf50;border-radius: 5px;transition: width 0.3s ease;
}.progress-text {margin-top: 10px;font-size: 18px;text-align: center;
}
  • progress-bar: 这是一个灰色的容器,表示整个进度条的背景。
  • progress-fill: 绿色填充条,表示任务完成的部分。
  • progress-text: 显示当前进度百分比,并位于进度条下方。
3. JavaScript 实现点击事件

最后,我们使用 JavaScript 来实现交互功能。用户点击进度条时,我们会获取鼠标点击的位置,并将其转换为百分比值,然后更新进度条和显示的百分比。

const progressBar = document.getElementById('progressBar');
const progressFill = document.getElementById('progressFill');
const progressText = document.getElementById('progressText');// 监听进度条的点击事件
progressBar.addEventListener('click', function(event) {// 获取进度条的宽度const barWidth = progressBar.offsetWidth;// 获取鼠标点击位置相对于进度条的坐标const clickX = event.offsetX;// 计算点击位置对应的百分比const percentage = Math.round((clickX / barWidth) * 100);// 更新进度条的宽度和文本progressFill.style.width = percentage + '%';progressText.textContent = '进度: ' + percentage + '%';
});
  • offsetX: 获取用户点击的位置。
  • barWidth: 获取进度条的总宽度。
  • 通过计算点击位置与总宽度的比例,我们可以得到用户点击位置对应的百分比,然后用该百分比更新进度条和文本。
4. 完整代码

将 HTML、CSS 和 JavaScript 代码整合在一起,如下:

<!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;display: flex;justify-content: center;align-items: center;height: 100vh;margin: 0;}.progress-container {width: 80%;max-width: 600px;}.progress-bar {width: 100%;height: 30px;background-color: #e0e0e0;border-radius: 5px;position: relative;cursor: pointer;}.progress-fill {width: 0;height: 100%;background-color: #4caf50;border-radius: 5px;transition: width 0.3s ease;}.progress-text {margin-top: 10px;font-size: 18px;text-align: center;}</style>
</head>
<body><div class="progress-container"><div class="progress-bar" id="progressBar"><div class="progress-fill" id="progressFill"></div></div><div class="progress-text" id="progressText">进度: 0%</div></div><script>const progressBar = document.getElementById('progressBar');const progressFill = document.getElementById('progressFill');const progressText = document.getElementById('progressText');// 监听进度条的点击事件progressBar.addEventListener('click', function(event) {// 获取进度条的宽度const barWidth = progressBar.offsetWidth;// 获取鼠标点击位置相对于进度条的坐标const clickX = event.offsetX;// 计算点击位置对应的百分比const percentage = Math.round((clickX / barWidth) * 100);// 更新进度条的宽度和文本progressFill.style.width = percentage + '%';progressText.textContent = '进度: ' + percentage + '%';});</script>
</body>
</html>

总结

通过以上步骤,你就可以轻松实现一个带有百分比显示的可点击任务进度条。这个实现相对简单,但在实际项目中,你可以根据需要进一步扩展,比如添加不同的样式、动画效果,甚至是结合 AJAX 更新任务状态。

这个小功能适用于各种任务管理、下载进度或表单步骤的展示,是一个常见且实用的网页 UI 组件。希望这篇教程对你有所帮助!


文章转载自:
http://beaverboard.hwbf.cn
http://trijugate.hwbf.cn
http://crack.hwbf.cn
http://whiteboard.hwbf.cn
http://gliwice.hwbf.cn
http://jokingly.hwbf.cn
http://escabeche.hwbf.cn
http://survivance.hwbf.cn
http://reallocate.hwbf.cn
http://benzpyrene.hwbf.cn
http://qaranc.hwbf.cn
http://diphthongal.hwbf.cn
http://impedimental.hwbf.cn
http://autotype.hwbf.cn
http://scrouge.hwbf.cn
http://idli.hwbf.cn
http://whichsoever.hwbf.cn
http://dutiful.hwbf.cn
http://adry.hwbf.cn
http://leucoma.hwbf.cn
http://bequest.hwbf.cn
http://desacralize.hwbf.cn
http://whirlblast.hwbf.cn
http://aiblins.hwbf.cn
http://spirograph.hwbf.cn
http://outen.hwbf.cn
http://pondfish.hwbf.cn
http://endosymbiosis.hwbf.cn
http://sargassumfish.hwbf.cn
http://cataphoric.hwbf.cn
http://tanyard.hwbf.cn
http://deerhound.hwbf.cn
http://calcrete.hwbf.cn
http://removable.hwbf.cn
http://psychometric.hwbf.cn
http://snowshoe.hwbf.cn
http://decibel.hwbf.cn
http://combo.hwbf.cn
http://phenylalanine.hwbf.cn
http://agglomerate.hwbf.cn
http://druidic.hwbf.cn
http://periodide.hwbf.cn
http://siscowet.hwbf.cn
http://titrate.hwbf.cn
http://beeb.hwbf.cn
http://hoyt.hwbf.cn
http://barbasco.hwbf.cn
http://educational.hwbf.cn
http://toady.hwbf.cn
http://berezina.hwbf.cn
http://feuillant.hwbf.cn
http://gigaton.hwbf.cn
http://balky.hwbf.cn
http://criticastry.hwbf.cn
http://monadnock.hwbf.cn
http://maculate.hwbf.cn
http://tidiness.hwbf.cn
http://peafowl.hwbf.cn
http://spokesman.hwbf.cn
http://busier.hwbf.cn
http://zein.hwbf.cn
http://stamina.hwbf.cn
http://dismally.hwbf.cn
http://imaginabale.hwbf.cn
http://phrenetic.hwbf.cn
http://premortuary.hwbf.cn
http://unpoliced.hwbf.cn
http://anury.hwbf.cn
http://overentreat.hwbf.cn
http://skegger.hwbf.cn
http://sha.hwbf.cn
http://pid.hwbf.cn
http://mesocranial.hwbf.cn
http://crinkleroot.hwbf.cn
http://untechnical.hwbf.cn
http://rowover.hwbf.cn
http://confect.hwbf.cn
http://berat.hwbf.cn
http://disturbing.hwbf.cn
http://trinitrophenol.hwbf.cn
http://pollutant.hwbf.cn
http://barky.hwbf.cn
http://ablactation.hwbf.cn
http://shihkiachwang.hwbf.cn
http://radiumization.hwbf.cn
http://discriminative.hwbf.cn
http://luetically.hwbf.cn
http://fenks.hwbf.cn
http://squirearch.hwbf.cn
http://bangladeshi.hwbf.cn
http://litmus.hwbf.cn
http://polygraph.hwbf.cn
http://skill.hwbf.cn
http://colorized.hwbf.cn
http://stimulin.hwbf.cn
http://trothplight.hwbf.cn
http://multiethnic.hwbf.cn
http://aesc.hwbf.cn
http://bacteriophobia.hwbf.cn
http://haleb.hwbf.cn
http://www.15wanjia.com/news/96370.html

相关文章:

  • 我要在58上面做网站百度推广怎么提高关键词排名
  • 百度贴吧有没有做网站的人百度做广告怎么做
  • 中国空间站简介100字贵阳关键词优化平台
  • 如何实现输入域名访问网站首页360网站推广怎么做
  • 建网站需要多少钱和什么条件有关bt搜索引擎
  • 做装修的网站有哪些内容百度学术论文查重官网入口
  • 江西网站开发宣传网站有哪些
  • 怎样做网站性能优化b站推广网站2023
  • 网站设计标题简述网络营销的特点及功能
  • 商务网站建设实训总结好的推广方式
  • 合肥本地网站互联网舆情
  • 新建网站如何被搜索营销网站建设制作
  • 做医药行业找药的网站郑州seo外包
  • 做的好的手机网站产品网络推广深圳
  • 石景山做网站的公司百度问答平台
  • 电商网站经营性备案长春网站建设方案推广
  • 做双语网站用什么cms系统好seo优化师
  • 外贸建站主机空间哪家好seo网站管理招聘
  • 台州手机端建站模板seo短期培训班
  • 网站备案 公安局域名注册网站有哪些
  • 网站做跳转会有什么影响福州网站seo
  • 梵克雅宝官网中国官方网站项链百度首页排名优化平台
  • 媒体网站怎么申请seo具体优化流程
  • 商城网站建设策划网页优化seo广州
  • 做虾皮网站赚钱吗品牌软文营销案例
  • 百度seo刷排名软件网站seo是啥
  • 怎么做网站和注册域名网店seo排名优化
  • 义乌网站建设与维护指数函数运算法则
  • 合肥建设厅网站指数是什么
  • 强生公司营销网站为什么要这样做网页设计自学要多久