利用 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 相关文章推荐
jquery.validate分组验证代码
Mar 17 Javascript
Javascript 多浏览器兼容总结(实战经验)
Oct 30 Javascript
JQUERY 设置SELECT选中项代码
Feb 07 Javascript
ajaxFileUpload.js插件支持多文件上传的方法
Sep 02 Javascript
AngularJS身份验证的方法
Feb 17 Javascript
Angularjs中使用layDate日期控件示例
Jan 11 Javascript
基于Vuejs和Element的注册插件的编写方法
Jul 03 Javascript
node.js的exports、module.exports与ES6的export、export default深入详解
Oct 26 Javascript
对Vue beforeRouteEnter 的next执行时机详解
Aug 25 Javascript
webpack3里使用uglifyjs压缩js时打包报错的解决
Dec 13 Javascript
swiper4实现移动端导航切换
Oct 16 Javascript
JS出现404错误原理及解决方案
Jul 01 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
PHP入门
2006/10/09 PHP
phpmailer发送邮件之后,返回收件人是否阅读了邮件的方法
2014/07/19 PHP
PHP实现长轮询消息实时推送功能代码实例讲解
2021/02/26 PHP
用jquery来定位
2007/02/20 Javascript
js 获取子节点函数 (兼容FF与IE)
2010/04/18 Javascript
JQuery跨Iframe选择实现代码
2010/08/19 Javascript
js 实现css风格选择器(压缩后2KB)
2012/01/12 Javascript
基于jQuery的烟花效果(运动相关)点击屏幕出烟花
2012/06/14 Javascript
Jquery中国地图热点效果-鼠标经过弹出提示层信息的简单实例
2014/02/12 Javascript
jQuery源码解读之removeClass()方法分析
2015/02/20 Javascript
JQuery菜单效果的两个实例讲解(3)
2015/09/17 Javascript
微信小程序 教程之数据绑定
2016/10/18 Javascript
JavaScript对象封装的简单实现方法(3种方法)
2017/01/03 Javascript
js放大镜放大购物图片效果
2017/01/18 Javascript
关于jQuery中fade(),show()起始位置的一点小发现
2017/04/25 jQuery
Angular设置别名alias的方法
2018/11/08 Javascript
用jQuery将JavaScript对象转换为querystring查询字符串的方法
2018/11/12 jQuery
开发中常用的25个JavaScript单行代码(小结)
2019/06/28 Javascript
小程序选项卡以及swiper套用(跨页面)
2020/06/19 Javascript
Vue+penlayers实现多边形绘制及展示
2020/12/24 Vue.js
python ElementTree 基本读操作示例
2009/04/09 Python
Python的Django框架中settings文件的部署建议
2015/05/30 Python
Python计算两个日期相差天数的方法示例
2017/05/23 Python
利用Python实现Windows下的鼠标键盘模拟的实例代码
2017/07/13 Python
Django缓存系统实现过程解析
2019/08/02 Python
Python urlopen()和urlretrieve()用法解析
2020/01/07 Python
Django实现简单的分页功能
2021/02/22 Python
Elemental Herbology官网:英国美容品牌
2019/04/27 全球购物
教师求职信范文分享
2013/12/27 职场文书
中学生寄语大全
2014/04/03 职场文书
东京审判观后感
2015/06/01 职场文书
人民调解协议书
2016/03/21 职场文书
Python中Cookies导出某站用户数据的方法
2021/05/17 Python
python 经纬度求两点距离、三点面积操作
2021/06/03 Python
mysql 联合索引生效的条件及索引失效的条件
2021/11/20 MySQL
基于Python实现一个春节倒计时脚本
2022/01/22 Python