展会信息港展会大全

css3中实现像flash中的时钟进度条
来源:互联网   发布日期:2016-03-25 16:29:22   浏览:1691次  

导读:本文章是通过了css3的transform属性来实现元素旋转(rotate)来实例,有需要的朋友可以参考一下。css:代码如下复制代码 <style>#cric...

本文章是通过了css3的transform属性来实现元素旋转(rotate)来实例,有需要的朋友可以参考一下。

css:

代码如下

复制代码

<style>

#cricle{width:200px;height:200px;position:relative;background:#333;overflow:hidden}

#cricle .left,#cricle .right,#cricle .text{width:200px;height:200px}

#cricle .text{position:absolute;top:0;left:0;z-index:41;color:#fff;font:26px/200px ′arial′;text-align:center}

#cricle .mask{z-index:40}

#cricle .mask,#cricle .bg{width:100px;height:200px;background:#333;position:absolute;top:0}

#cricle .bg{background:url(/2011/11/bg_green.png) no-repeat 0 0}

#cricle .mask,#cricle .left .bg{left:0}

#cricle .right{display:none}

#cricle .right .bg{background-position:right top;right:0}

</style>

html:

代码如下

复制代码

<div id="cricle">

<div class="mask"></div>

<div class="left">

<div class="bg"></div>

</div>

<div class="right">

<div class="bg"></div>

</div>

<div class="text"></div>

</div>

javascript:

代码如下

复制代码

<script>

var C = function(id){

this.box = $("#"+id);

this.left = this.box.find(".left");

this.right = this.box.find(".right");

this.mask = this.box.find(".mask");

this.text = this.box.find(".text");

this.d = 0;

this.A = null;

this.init();

}

C.prototype = {

init : function(){

var T = this;

this.A = window.setInterval(function(){T.change()},80);

},

change : function(){

var T = this;

if(this.d>180){

if(this.d>360){

window.clearInterval(this.A);

this.A = null;

return;

}

this.right.show();

this.mask.hide();

}

this.text.text(parseInt(this.d/3.6));

this.left.css({

"-webkit-transform":"rotate("+this.d+"deg)",

"-moz-transform":"rotate("+this.d+"deg)"

})

this.d += 6;

}

}

</script>

赞助本站

人工智能实验室

相关热词: 开发 编程 android

AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港