帮助中心
获取牛币
联系我们
关于我们
版权声明
素材牛首页
微博登录
QQ登录
微信扫码登录
注册
登录
新浪微博
QQ登陆
微信登录
热门搜索:
小程序
支付
Java
后台模板
上传
商城模板
jQuery
手机
Thinkphp
微信
Vue.js
首 页
网页特效
整站源码
PHP实例
网站模版
工具箱
常用代码
论坛
游戏源码
资源分享
当前位置:
首页
»
精选常用代码
» 超炫的HTML5+CSS3进度条
超炫的HTML5+CSS3进度条
浏览:667次
-
评论:0次
-
发布时间:2017-03-10
Html
Css
Js
body { background: #000; } canvas { background: #181818; box-shadow: 0 0 0 1px #282828; bottom: 0; left: 0; margin: auto; position: absolute; right: 0; top: 0; }
var canvas = document.createElement( 'canvas' ), ctx = canvas.getContext( '2d' ), width = 400 height = 100, loaded = 0, loaderSpeed = 0.6, loaderWidth = 310, loaderHeight = 16, loaderX = width / 2 - loaderWidth / 2, loaderY = height / 2 - loaderHeight / 2, particles = [], particleLift = 180, particleRate = 4, hueStart = 0, hueEnd = 120, hue = 0, gravity = 0.12; document.body.appendChild( canvas ); canvas.width = width; canvas.height = height; ctx.globalCompositeOperation = 'lighter'; function rand( rMi, rMa ) { return ~~((Math.random()*(rMa-rMi+1))+rMi); } function updateLoader() { if( loaded < 100 ) { loaded += loaderSpeed; } else { loaded = 0; } } function renderLoader() { ctx.fillStyle = '#000'; ctx.fillRect( loaderX, loaderY, loaderWidth, loaderHeight ); hue = hueStart + ( loaded / 100 ) * ( hueEnd - hueStart ); var newWidth = ( loaded / 100 ) * loaderWidth; ctx.fillStyle = 'hsla(' + hue + ', 100%, 40%, 1)'; ctx.fillRect( loaderX, loaderY, newWidth, loaderHeight ); ctx.fillStyle = '#444'; ctx.fillRect( loaderX, loaderY, newWidth, loaderHeight / 2 ); } function Particle() { this.x = loaderX + ( ( loaded / 100 ) * loaderWidth ) - rand( 0, 1 ); this.y = height / 2 + rand( 0, loaderHeight ) - loaderHeight / 2; this.vx = ( rand( 0, 4 ) - 2 ) / 100; this.vy = ( rand( 0, particleLift ) - particleLift * 2 ) / 100; this.width = rand( 1, 4 ) / 2; this.height = rand( 1, 4 ) / 2; this.hue = hue; } Particle.prototype.update = function( i ) { this.vx += ( rand( 0, 6 ) - 3 ) / 100; this.vy += gravity; this.x += this.vx; this.y += this.vy; if( this.y > height ) { particles.splice( i, 1 ); } }; Particle.prototype.render = function() { ctx.fillStyle = 'hsla(' + this.hue + ', 100%, ' + rand( 50, 70 ) + '%, ' + rand( 20, 100 ) / 100 + ')'; ctx.fillRect( this.x, this.y, this.width, this.height ); }; function createParticles() { var i = particleRate; while( i-- ) { this.particles.push( new Particle() ); } } function updateParticles() { var i = particles.length; while( i-- ) { var p = particles[ i ]; p.update( i ); }; } function renderParticles() { var i = particles.length; while( i-- ) { var p = particles[ i ]; p.render(); } } function clearCanvas() { ctx.clearRect( 0, 0, width, height ); } function loop() { requestAnimationFrame( loop ); clearCanvas(); createParticles(); updateLoader(); updateParticles(); renderLoader(); renderParticles(); } loop();
↑上面代码改变,会自动显示代码结果
jQuery调用版本:
1.11.3
<!doctype html><html><head><meta charset="utf-8"><title>超炫的HTML5+CSS3进度条-www.sucainiu.com</title><script src="https://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script><style>
</style></head><body>
<script>
</script>
</body></html>
立即下载
收藏
积分说明:注册即送10牛币,每日签到可获得5牛币,成为VIP会员可永久免牛币下载!
充值积分
充值会员
更多说明»
代码描述:超炫的进度条效果图
超级漂亮的进度条显示技术,炫酷
点击div之外的区域使div隐藏
立体弹窗效果
讨论这个常用代码(0)
回答他人问题或分享心得会奖励牛币
〒_〒 居然一个评论都没有……
文明上网,理性发言! 😉 阿里云幸运券,
戳我领取
发表评论
提交回复
我的积分余额:
0
已下载次数:
667
所需牛币:
5
开始下载
牛币获取:
签到、评论、充值
» 在线充值
(10牛币=1元)
成为VIP可永久免积分下载全部常用代码
» 查看详情
VIP
客服
签到
充值