利用 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 相关文章推荐
学习ExtJS TextField常用方法
Oct 07 Javascript
轻轻松松学JS调试(不下载任何工具)
Apr 14 Javascript
基于jQuery捕获超链接事件进行局部刷新代码
May 10 Javascript
javascript设计模式之中介者模式Mediator
Dec 30 Javascript
基于Bootstrap+jQuery.validate实现表单验证
May 30 Javascript
jquery网页日历显示控件calendar3.1使用详解
Nov 24 Javascript
Angular如何引入第三方库的方法详解
Jul 13 Javascript
使用jquery的jsonp如何发起跨域请求及其原理详解
Aug 17 jQuery
angular 服务随记小结
May 06 Javascript
基于ts的动态接口数据配置的详解
Dec 18 Javascript
JavaScript 链表定义与使用方法示例
Apr 28 Javascript
Vue循环中多个input绑定指定v-model实例
Aug 31 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
Windows下XDebug 手工配置与使用说明
2010/07/11 PHP
PHP处理Oracle的CLOB实例
2014/11/03 PHP
PHP Web木马扫描器代码分享
2015/09/06 PHP
PHP常用函数总结(180多个)
2016/12/25 PHP
在laravel中使用Symfony的Crawler组件分析HTML
2017/06/19 PHP
php求斐波那契数的两种实现方式【递归与递推】
2019/09/09 PHP
JS 日期比较大小的简单实例
2014/01/13 Javascript
ECMAScript5中的对象存取器属性:getter和setter介绍
2014/12/08 Javascript
JavaScript常用脚本汇总(二)
2015/03/04 Javascript
只要1K 纯JS脚本送你一朵3D红色玫瑰
2016/08/09 Javascript
微信小程序 自己制作小组件实例详解
2016/12/22 Javascript
EasyUi 打开对话框后控件赋值及赋值后不显示的问题解决办法
2017/01/19 Javascript
javascript获取以及设置光标位置
2017/02/16 Javascript
vue中的适配px2rem示例代码
2018/11/19 Javascript
node+vue实现文件上传功能
2020/05/28 Javascript
微信小程序实现modal弹出框遮罩层组件(可带文本框)
2020/12/20 Javascript
基于JavaScript实现随机点名器
2021/02/25 Javascript
[47:18]完美世界DOTA2联赛循环赛 IO vs FTD BO2第一场 11.05
2020/11/06 DOTA
python绘图库Matplotlib的安装
2014/07/03 Python
python django 实现验证码的功能实例代码
2017/05/18 Python
详解python上传文件和字符到PHP服务器
2017/11/24 Python
基于Pandas读取csv文件Error的总结
2018/06/15 Python
使用 Python 遍历目录树的方法
2020/02/29 Python
Numpy中ndim、shape、dtype、astype的用法详解
2020/06/14 Python
详解python datetime模块
2020/08/17 Python
Python tkinter实现日期选择器
2021/02/22 Python
推荐10个HTML5响应式框架
2016/02/25 HTML / CSS
Andrew Marc官网:设计师外套的领先制造商
2019/10/30 全球购物
写一个函数返回1+2+3+…+n的值(假定结果不会超过长整型变量的范围)
2014/09/05 面试题
土木工程师岗位职责
2013/11/24 职场文书
作文批改评语大全
2014/04/23 职场文书
施工安全汇报材料
2014/08/17 职场文书
环卫工作汇报材料
2014/10/28 职场文书
水电工程师岗位职责
2015/02/13 职场文书
什么是检讨书?检讨书的格式及范文
2019/11/05 职场文书
python爬虫之selenium库的安装及使用教程
2021/05/23 Python