利用 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 相关文章推荐
用roll.js实现的图片自动滚动+鼠标触动的特效
Mar 18 Javascript
js电信网通双线自动选择技巧
Nov 18 Javascript
禁止js文件缓存的代码
Apr 09 Javascript
使用jQuery操作Cookies的实现代码
Oct 09 Javascript
解决ueditor jquery javascript 取值问题
Dec 30 Javascript
JavaScript中使用指数方法Math.exp()的简介
Jun 15 Javascript
jQuery实用技巧必备(上)
Nov 02 Javascript
使用getBoundingClientRect方法实现简洁的sticky组件的方法
Mar 22 Javascript
Jquery实现select multiple左右添加和删除功能的简单实例
May 26 Javascript
从零开始学习Node.js系列教程一:http get和post用法分析
Apr 13 Javascript
一个可复用的vue分页组件
May 15 Javascript
JS图片预加载插件详解
Jun 21 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
Linux操作系统安装LAMP环境
2015/06/26 PHP
WordPress中重置文章循环的rewind_posts()函数讲解
2016/01/11 PHP
PHP编程文件处理类SplFileObject和SplFileInfo用法实例分析
2017/07/22 PHP
laravel 使用auth编写登录的方法
2019/09/30 PHP
PHP ElasticSearch做搜索实例讲解
2020/02/05 PHP
jQuery EasyUI API 中文文档 - NumberBox数字框
2011/10/13 Javascript
浅谈JavaScript function函数种类
2014/12/29 Javascript
jquery动态切换背景图片的简单实现方法
2016/05/14 Javascript
JS实现点击表头表格自动排序(含数字、字符串、日期)
2017/01/22 Javascript
js 原型对象和原型链理解
2017/02/09 Javascript
JavaScript表单验证实现代码
2017/05/22 Javascript
微信小程序数据存储与取值详解
2018/01/30 Javascript
setTimeout时间设置为0详细解析
2018/03/13 Javascript
jquery.onoff实现简单的开关按钮功能(推荐)
2018/05/24 jQuery
深入浅析JS中的严格模式
2018/06/04 Javascript
js数组去重的方法总结
2019/01/18 Javascript
个人小程序接入支付解决方案
2019/05/23 Javascript
Nodejs监控事件循环异常示例详解
2019/09/22 NodeJs
vue源码中的检测方法的实现
2019/09/26 Javascript
浅谈webpack和webpack-cli模块源码分析
2020/01/19 Javascript
JavaScript canvas绘制渐变颜色的矩形
2020/02/18 Javascript
Python FTP操作类代码分享
2014/05/13 Python
使用graphics.py实现2048小游戏
2015/03/10 Python
有关Tensorflow梯度下降常用的优化方法分享
2020/02/04 Python
selenium+python配置chrome浏览器的选项的实现
2020/03/18 Python
OpenCV Python实现拼图小游戏
2020/03/23 Python
PyCharm Anaconda配置PyQt5开发环境及创建项目的教程详解
2020/03/24 Python
Python限制内存和CPU使用量的方法(Unix系统适用)
2020/08/04 Python
Python Opencv实现单目标检测的示例代码
2020/09/08 Python
利用CSS3实现炫酷的飞机起飞动画
2016/09/17 HTML / CSS
css3实现的多级渐变下拉菜单导航效果代码
2015/08/31 HTML / CSS
餐饮业员工工作决心书
2014/03/11 职场文书
百日安全生产活动总结
2014/07/05 职场文书
龙门石窟导游词
2015/02/02 职场文书
英语教师个人工作总结
2015/02/09 职场文书
JavaScript offset实现鼠标坐标获取和窗口内模块拖动
2021/05/30 Javascript