前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >水平线上涨loading实现原理

水平线上涨loading实现原理

作者头像
用户1730674
发布2018-05-02 10:38:47
7620
发布2018-05-02 10:38:47
举报
文章被收录于专栏:我分享我快乐

前期准备:需要一张水平线荡漾图片,格式为png或svg

代码实现如下:

<!doctype html>

<html>

<head>

<script src="jquery.js"></script>

<script>

$(document).ready(function(e) {

var n=0,t=100,num=0

function toleft(){

if(n>-200){

$(".circle img").css({left:n--})

}else{n=0}

}

var tleft=setInterval(toleft,3)

function totop(){

if(t>0){

$(".circle img").css({top:t--})

}else{t=100}

}

var ttop=setInterval(totop,100)

function numup(){

if(num<100){

num++

}else{

num=0

}

$(".circle span").html(num+"%")

}

var tnum=setInterval(numup,100)

});

</script>

<style>

body{background-color:black;}

.circle{left:50%;margin-left:-100px;background-color:rgba(0%,80%,100%,0.5);width:200px;height:200px;border-radius:50%;overflow:hidden;position:relative;top:100px;}

.circle img{position:relative;left:0;top:100px;}

.circle span{width:80px;position:absolute;left:50%;top:120px;margin-left:-40px;color:rgba(255,255,255,0.5);font-size:50px;font-family:Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;text-align:center;}

</style>

<meta charset="utf-8">

<title>无标题文档</title>

</head>

<body>

<div class="circle">

<img src="water.svg">

<span></span>

</div>

</body>

</html>

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2016-11-03,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 我分享我快乐 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档