利用 spin.js 生成等待效果(js 等待效果)


Posted in Javascript onJune 25, 2017

利用 js 生成一个界面友好的等待效果,使用 jquery 插件 spin.js,文章末尾有下载地址,下图是生成的效果截图,代码调用很简单。

利用 spin.js 生成等待效果(js 等待效果)

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
body {
 font-family: Helvetica, Arial, sans-serif; font-size: 12px;
}
#preview1 {
 float: left; position: relative; background-color: #000; color: black; width: 220px; height: 220px; margin: 0 5px; border-radius: 20px;
}
#preview2 {
 float: left; position: relative; background-color: #000; color: black; width: 220px; height: 220px; margin: 0 5px; border-radius: 20px;
}
</style>
<script src="jquery.min.js"></script>
<script src="spin.js"></script>
<script src="jquery.spin.js"></script>
<script type="text/javascript">
 // 对样式 #preview1 进行配置
 var opts1 =
 {
 lines : 12, // The number of lines to draw
 length : 0, // The length of each line
 width : 11, // The line thickness
 radius : 40, // The radius of the inner circle
 scale : 1.0, // Scales overall size of the spinner
 corners : 0, // Roundness (0..1)
 color : '#efefef', // #rgb or #rrggbb
 opacity : 1 / 4, // Opacity of the lines
 rotate : 0, // Rotation offset
 direction : 1, // 1: clockwise, -1: counterclockwise
 speed : 1, // Rounds per second
 trail : 100, // Afterglow percentage
 fps : 20, // Frames per second when using setTimeout()
 zIndex : 2e9, // Use a high z-index by default
 className : 'spinner', // CSS class to assign to the element
 top : '50%', // center vertically
 left : '50%', // center horizontally
 shadow : false, // Whether to render a shadow
 hwaccel : false, // Whether to use hardware acceleration (might be buggy)
 position : 'absolute' // Element positioning
 };
 // 对样式 #preview2 进行配置
 var opts2 =
 {
 lines : 18, // The number of lines to draw
 length : 0, // The length of each line
 width : 11, // The line thickness
 radius : 40, // The radius of the inner circle
 scale : 1.0, // Scales overall size of the spinner
 corners : 0, // Roundness (0..1)
 color : 'red', // #rgb or #rrggbb
 opacity : 1 / 4, // Opacity of the lines
 rotate : 0, // Rotation offset
 direction : 1, // 1: clockwise, -1: counterclockwise
 speed : 1, // Rounds per second
 trail : 100, // Afterglow percentage
 fps : 20, // Frames per second when using setTimeout()
 zIndex : 2e9, // Use a high z-index by default
 className : 'spinner', // CSS class to assign to the element
 top : '50%', // center vertically
 left : '50%', // center horizontally
 shadow : false, // Whether to render a shadow
 hwaccel : false, // Whether to use hardware acceleration (might be buggy)
 position : 'absolute' // Element positioning
 };
</script>
<title>Insert title here</title>
</head>
<body>
 <div id="preview1" class="preview"></div>
 <div id="preview2" class="preview"></div>
</body>
<script type="text/javascript">
 $('#preview1').spin(opts1);
 $('#preview2').spin(opts2);
</script>
</html>

插件下载地址

https://github.com/fgnass/spin.js/

http://spin.js.org/

以上所述是小编给大家介绍的利用 spin.js 生成等待效果(js 等待效果),希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!

Javascript 相关文章推荐
地震发生中逃生十大法则
May 12 Javascript
js tab效果的实现代码
Dec 26 Javascript
javascript实现面向对象类的功能书写技巧
Mar 07 Javascript
JavaScript 拾碎[三] 使用className属性
Oct 16 Javascript
jQuery Clone Bug解决代码
Dec 22 Javascript
JavaScript将一个数组插入到另一个数组的方法
Mar 19 Javascript
JQuery Mobile实现导航栏和页脚
Mar 09 Javascript
javascript简易画板开发
Apr 12 Javascript
JS常用加密编码与算法实例总结
Dec 22 Javascript
使用SVG基本操作API的实例讲解
Sep 14 Javascript
js实现手机web图片左右滑动效果
Dec 29 Javascript
electron + vue项目实现打印小票功能及实现代码
Nov 25 Javascript
Bootstrap模态框插入视频的实现代码
Jun 25 #Javascript
Angular中的interceptors拦截器
Jun 25 #Javascript
Angular中的$watch、$watchGroup、$watchCollection
Jun 25 #Javascript
JS实现加载时锁定HTML页面元素的方法
Jun 24 #Javascript
Angular2.js实现表单验证详解
Jun 23 #Javascript
JS实现多张图片预览同步上传功能
Jun 23 #Javascript
Vue组件化通讯的实例代码
Jun 23 #Javascript
You might like
Terran建筑一览
2020/03/14 星际争霸
一步一步学习PHP(3) php 函数
2010/02/15 PHP
获取php页面执行时间,数据库读写次数,函数调用次数等(THINKphp)
2013/06/03 PHP
php+redis实现商城秒杀功能
2020/11/19 PHP
laravel框架中表单请求类型和CSRF防护实例分析
2019/11/23 PHP
JQuery与Ajax常用代码实现对比
2009/10/03 Javascript
js href的用法
2010/05/13 Javascript
dess中一个简单的多路委托的实现
2010/07/20 Javascript
JavaScript中的style.display属性操作
2013/03/27 Javascript
javaScript实现浮点数转十六进制字符
2013/10/29 Javascript
使用js判断数组中是否包含某一元素(类似于php中的in_array())
2013/12/12 Javascript
JS实现模仿微博发布效果实例代码
2013/12/16 Javascript
jquery的ajax异步请求接收返回json数据实例
2014/06/16 Javascript
JS实现网页右侧带动画效果的伸缩窗口代码
2015/10/29 Javascript
jQuery插件formValidator自定义函数扩展功能实例详解
2015/11/25 Javascript
node.js的exports、module.exports与ES6的export、export default深入详解
2017/10/26 Javascript
详解基于mpvue的小程序markdown适配解决方案
2018/05/08 Javascript
vue  directive定义全局和局部指令及指令简写
2018/11/20 Javascript
webpack4 从零学习常用配置(小结)
2019/05/28 Javascript
JavaScript 判断数据类型的4种方法
2020/09/11 Javascript
Python实现提取谷歌音乐搜索结果的方法
2015/07/10 Python
python用Pygal如何生成漂亮的SVG图像详解
2017/02/10 Python
Django 实现下载文件功能的示例
2018/03/06 Python
django利用request id便于定位及给日志加上request_id
2018/08/26 Python
详解python3 + Scrapy爬虫学习之创建项目
2019/04/12 Python
解决Python安装时报缺少DLL问题【两种解决方法】
2019/07/15 Python
Python xlwt模块使用代码实例
2020/06/10 Python
python在一个范围内取随机数的简单实例
2020/08/16 Python
详解python 支持向量机(SVM)算法
2020/09/18 Python
CSS3实现超酷的黑猫警长首页
2016/04/26 HTML / CSS
HTML5全屏(Fullscreen)API详细介绍
2015/04/24 HTML / CSS
大学应届生求职简历的自我评价
2013/10/08 职场文书
2015国庆66周年宣传语
2015/07/14 职场文书
企业愿景口号
2015/12/25 职场文书
导游词之山西关帝庙
2019/11/01 职场文书
Python 中数组和数字相乘时的注意事项说明
2021/05/10 Python