web前端|css教程
css,js,动态进度条
web前端-css教程
css+js如何实现简单的动态进度条?本篇文章就给大家用css+js制作一个简单的动态进度条效果,并将页面动态进度条滚动加载的代码分享给大家,感兴趣的小伙伴可以参考借鉴一下,希望对你们有所帮助。
搜索框 源码,ubuntu精简包列表,Linux系统爬虫部署,php –,杏坛seo推广lzw
我们要知道,这里主要使用了css3的animation动画属性,首先将进度条设置为一个初始宽度为0,背景色为绿色,高度与容器相同的元素;在通过animation动画属性对其宽度进行过渡,从而实现进度条填充的效果。
威客接单推广网站源码,vscode中rg,ubuntu开启桌面环境,crt 启动tomcat,网页调用本地sqlite,百家cms 插件,前端框架导航怎么切换,神马爬虫影,php 增加,seo常用的标签,网站cms后台管理系统下载,网页微信二维码,织梦展览会网站模板下载,仿美团 酒店页面,小区物业管理系统代码,图片网站源程序lzw
我们来看看css3的animation动画属性的相关知识。
08影院视频网站最新源码,q5 ubuntu,tomcat7与8比较,网络爬虫 规则设置,php现在还适合学吗,商品内容seolzw
animation 属性是一个简写属性,用于设置六个动画属性:
animation-name:规定需要绑定到选择器的 keyframe 名称;
animation-duration:规定完成动画所花费的时间,以秒或毫秒计;
animation-timing-function:规定动画的速度曲线;
animation-delay:规定在动画开始之前的延迟;
animation-iteration-count:规定动画应该播放的次数;
animation-direction:规定是否应该轮流反向播放动画
下面我们来看看具体的实现动态进度条效果的方法。
css+js实现简单的动态进度条效果的代码示例:
html代码:
css代码:
#wrapper{ position: relative; width:200px; height:100px; border:1px solid darkgray;}#progressbar{ position: absolute; top:50%; left:50%; margin-left:-90px; margin-top:-10px; width:180px; height:20px; border:1px solid darkgray;}/*在进度条元素上调用动画*/#fill{ animation: move 2s; text-align: center; background-color: #6caf00;}/*实现元素宽度的过渡动画效果*/@keyframes move { 0%{ width:0; } 100%{ width:100%; }}
js代码:
var progressbar={ init:function(){ var fill=document.getElementById(fill); var count=0; //通过间隔定时器实现百分比文字效果,通过计算CSS动画持续时间进行间隔设置 var timer=setInterval(function(e){ count++; fill.innerHTML=count+\%; if(count===100) clearInterval(timer); },17); }};progressbar.init();
效果图:
总结: