利用 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 相关文章推荐
js 数组操作代码集锦
Apr 28 Javascript
javascript 表单规则集合对象
Jul 21 Javascript
js中eval()函数和trim()去掉字符串左右空格应用
Feb 02 Javascript
浅析Js(Jquery)中,字符串与JSON格式互相转换的示例(直接运行实例)
Jul 09 Javascript
ExtJS自定义主题(theme)样式详解
Nov 18 Javascript
javascript跨域的方法汇总
Oct 23 Javascript
简单了解Backbone.js的Model模型以及View视图的源码
Feb 14 Javascript
Bootstrap的Refresh Icon也spin起来
Jul 13 Javascript
Webpack如何引入bootstrap的方法
Jun 17 Javascript
微信小程序实现皮肤功能(夜间模式)
Jun 18 Javascript
微信小程序项目总结之点赞 删除列表 分享功能
Jun 25 Javascript
javascript创建元素和删除元素实例小结
Jun 19 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
不用数据库的多用户文件自由上传投票系统(1)
2006/10/09 PHP
基于php无限分类的深入理解
2013/06/02 PHP
PHP is_array() 检测变量是否是数组的实现方法
2016/06/13 PHP
Yii2验证器(Validator)用法分析
2016/07/23 PHP
PHP实现上传多文件示例代码
2017/02/20 PHP
PHP扩展mcrypt实现的AES加密功能示例
2019/01/29 PHP
laravel实现一个上传图片的接口,并建立软链接,访问图片的方法
2019/10/12 PHP
jquery validate使用攻略 第四步
2010/07/01 Javascript
jquery 学习之一 对象访问
2010/11/23 Javascript
基于jQuery的一个扩展form序列化到json对象
2010/12/09 Javascript
用js的for循环获取radio选中的值
2013/10/21 Javascript
jQuery插件boxScroll实现图片轮播特效
2015/07/14 Javascript
浅析AMD CMD CommonJS规范--javascript模块化加载学习心得总结
2016/03/16 Javascript
页面get请求 中文参数方法乱码问题的快速解决方法
2016/05/31 Javascript
浅析script标签中的defer与async属性
2016/11/30 Javascript
JS FormData上传文件的设置方法
2017/07/05 Javascript
JS 实现banner图片轮播效果(鼠标事件)
2017/08/04 Javascript
ES6学习教程之模板字符串详解
2017/10/09 Javascript
vue+webpack 打包文件 404 页面空白的解决方法
2018/02/28 Javascript
vue iView 上传组件之手动上传功能
2018/03/16 Javascript
vue.js项目nginx部署教程
2018/04/05 Javascript
如何用input标签和jquery实现多图片的上传和回显功能
2018/05/16 jQuery
python实现汉诺塔递归算法经典案例
2021/03/01 Python
Python中super()函数简介及用法分享
2016/07/11 Python
对python opencv 添加文字 cv2.putText 的各参数介绍
2018/12/05 Python
python初学者,用python实现基本的学生管理系统(python3)代码实例
2019/04/10 Python
python实现邮件自动发送
2019/08/10 Python
python实现登录密码重置简易操作代码
2019/08/14 Python
python通过对字典的排序,对json字段进行排序的实例
2020/02/27 Python
如何写出高性能的JSP和Servlet
2013/01/22 面试题
自我鉴定200字
2013/10/28 职场文书
快餐店的创业计划书范文
2014/01/29 职场文书
增员口号大全
2014/06/18 职场文书
大学生党校培训心得体会
2014/09/11 职场文书
生产操作工岗位职责
2014/09/16 职场文书
css position fixed 左右双定位的实现代码
2021/04/29 HTML / CSS