HTML实现进度条/加载框模版
HTML加载
- 一、环形加载 1
- 二、环形加载 2
- 三、波形加载
- 四、百分比环形
- 五、进度条
一、环形加载 1
.loader { border: 16px solid #f3f3f3; border-radius: 50%; border-top: 16px solid #3498db; width: 120px; height: 120px; -webkit-animation: spin 2s linear infinite; animation: spin 2s linear infinite; } @-webkit-keyframes spin { 0% { -webkit-transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); } } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }二、环形加载 2
.loader { border: 16px solid #f3f3f3; border-radius: 50%; border-top: 16px solid blue; border-bottom: 16px solid blue; width: 120px; height: 120px; -webkit-animation: spin 2s linear infinite; animation: spin 2s linear infinite; } @-webkit-keyframes spin { 0% { -webkit-transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); } } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }三、波形加载
.placeholder { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: #fff; } .loading { width: 80px; height: 40px; margin: 0 auto; margin-top: 100px; } .loading span { display: inline-block; width: 8px; height: 100%; border-radius: 4px; background: lightgreen; -webkit-animation: load 1s ease infinite; } @-webkit-keyframes load { 0%, 100% { height: 40px; background: lightgreen; } 50% { height: 70px; margin: -15px 0; background: lightblue; } } .loading span:nth-child(2) { -webkit-animation-delay: 0.2s; } .loading span:nth-child(3) { -webkit-animation-delay: 0.4s; } .loading span:nth-child(4) { -webkit-animation-delay: 0.6s; } .loading span:nth-child(5) { -webkit-animation-delay: 0.8s; }四、百分比环形
window.onload = function() { var canvas = document.getElementById('canvas'), // 获取canvas元素 context = canvas.getContext('2d'), // 获取画图环境,指明为2d centerX = canvas.width/2, // Canvas中心点x轴坐标 centerY = canvas.height/2, // Canvas中心点y轴坐标 rad = Math.PI*2/100, // 将360度分成100份 speed = 0.1; // 加载的快慢 // 绘制5像素宽的运动外圈 function blueCircle(n) { context.save(); context.strokeStyle = "#fff"; // 设置描边样式 context.lineWidth = 5; // 设置线宽 context.beginPath(); // 路径开始 context.arc(centerX, centerY, 100 , -Math.PI/2, -Math.PI/2 +n*rad, false); // 用于绘制圆弧 context.stroke(); // 绘制 context.closePath(); // 路径结束 context.restore(); } // 绘制白色外圈 function whiteCircle() { context.save(); context.beginPath(); context.lineWidth = 2; // 设置线宽 context.strokeStyle = "red"; context.arc(centerX, centerY, 100 , 0, Math.PI*2, false); context.stroke(); context.closePath(); context.restore(); } // 百分比文字绘制 function text(n) { context.save(); // 保证样式属性只运用于该段 canvas 元素 context.strokeStyle = "#fff"; // 设置描边样式 context.font = "40px Arial"; // 设置字体大小和字体 // 字 context.strokeText(n.toFixed(0)+"%", centerX-25, centerY+10); context.stroke(); // 绘制 context.restore(); } // 动画循环 (function drawFrame() { window.requestAnimationFrame(drawFrame); context.clearRect(0, 0, canvas.width, canvas.height); whiteCircle(); text(speed); blueCircle(speed); if(speed > 100) speed = 0; speed += 0.1; }()); }五、进度条
装载
免责声明:我们致力于保护作者版权,注重分享,被刊用文章因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理! 图片声明:本站部分配图来自人工智能系统AI生成,觅知网授权图片,PxHere摄影无版权图库和百度,360,搜狗等多加搜索引擎自动关键词搜索配图,如有侵权的图片,请第一时间联系我们,邮箱:ciyunidc@ciyunshuju.com。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!
