利用 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 相关文章推荐
JavaScript 应用技巧集合[推荐]
Aug 30 Javascript
日期处理的js库(迷你版)--自建js库总结
Nov 21 Javascript
jQuery实现id模糊查询的小例子
Mar 19 Javascript
jQuery插件 selectToSelect使用方法
Oct 02 Javascript
javascript继承机制实例详解
Nov 20 Javascript
JavaScript获取伪元素(Pseudo-Element)属性的方法技巧
Mar 13 Javascript
JS实现鼠标滑过折叠与展开菜单效果代码
Sep 06 Javascript
js倒计时简单实现方法
Dec 17 Javascript
js类式继承与原型式继承详解
Apr 07 Javascript
Node.js Sequelize如何实现数据库的读写分离
Oct 23 Javascript
AngularJS入门教程之与服务器(Ajax)交互操作示例【附完整demo源码下载】
Nov 02 Javascript
vue给组件传递不同的值方法
Sep 29 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
sony ICF-2010 拆解与改装
2021/03/02 无线电
PHP脚本的10个技巧(5)
2006/10/09 PHP
PHP动态规划解决0-1背包问题实例分析
2015/03/23 PHP
学习php设计模式 php实现工厂模式(factory)
2015/12/07 PHP
PHP异步进程助手async-helper
2018/02/05 PHP
PHP使用Curl实现模拟登录及抓取数据功能示例
2018/04/27 PHP
laravel 配置路由 api和web定义的路由的区别详解
2019/09/03 PHP
jquery中实现标签切换效果的代码
2011/03/01 Javascript
ajax的hide隐藏问题解决方法
2012/12/11 Javascript
JQuery操作元素的css样式
2015/03/09 Javascript
jQuery实现预加载图片的方法
2015/03/17 Javascript
javascript正则表达式基础知识入门
2015/04/20 Javascript
javascript实现炫酷的拖动分页
2015/05/11 Javascript
JavaScript性能优化之函数节流(throttle)与函数去抖(debounce)
2016/08/11 Javascript
浅谈js之字面量、对象字面量的访问、关键字in的用法
2016/11/20 Javascript
JS中用childNodes获取子元素换行会产生一个子元素
2016/12/08 Javascript
微信小程序上滑加载下拉刷新(onscrollLower)分批加载数据(二)
2017/05/11 Javascript
vue的无缝滚动组件vue-seamless-scroll实例
2017/12/18 Javascript
Nodejs中获取当前函数被调用的行数及文件名详解
2018/12/12 NodeJs
JavaScript实现选项卡效果的分析及步骤
2019/04/16 Javascript
ES6 Symbol数据类型的应用实例分析
2019/06/26 Javascript
vue3.0实现点击切换验证码(组件)及校验
2020/11/18 Vue.js
[07:39]第一届亚洲邀请赛回顾视频
2017/02/14 DOTA
python写的一个文本编辑器
2014/01/23 Python
Python CSV模块使用实例
2015/04/09 Python
Python中的深拷贝和浅拷贝详解
2015/06/03 Python
python实现简单ftp客户端的方法
2015/06/28 Python
python正则分析nginx的访问日志
2017/01/17 Python
python代码实现ID3决策树算法
2017/12/20 Python
Python调用C语言的方法【基于ctypes模块】
2018/01/22 Python
Python:type、object、class与内置类型实例
2019/12/25 Python
Django接收照片储存文件的实例代码
2020/03/07 Python
pytorch 查看cuda 版本方式
2020/06/23 Python
python 用opencv实现图像修复和图像金字塔
2020/11/27 Python
公司担保书格式范文
2014/05/12 职场文书
母亲节感言
2015/08/03 职场文书