[转] 魔兽技能冷却效果(绝佳思路)

非常非常的聪明的方法, 有创意, 五体投地


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <body>
<style>
.button { position:relative; width:65px; height:65px; overflow:hidden; border:3px outset #ddd; float:left; }
.layer { position:absolute; overflow: hidden; filter: Chroma(color='black') alpha(opacity=70); -moz-opacity:0.7; -khtml-opacity:0.7; opacity: 0.7; }
</style>
<script>
//By:X!ao_f QQ:120000512
function CoolDown(obj, time){ //定义DIV数组
var layers = [document.createElement('div'), document.createElement('div'), document.createElement('div'), document.createElement('div') ];
//重设
obj.reset = function(){
//附加DIV的样式
var styles = [
{ width: '0px', height: '0px', left:'33px', top:'-33px', border: '33px solid gray', borderTop: '33px solid transparent', borderLeft: '0px solid transparent' },
{ width: '0px', height: '0px', left:'33px', top:'33px', border: '33px solid gray', borderTop: '0px solid transparent', borderRight: '33px solid transparent' },
{ width: '33px', height: '0px', left:'-33px', top:'33px', border: '33px solid gray', borderBottom: '33px solid transparent', borderRight: '0px solid transparent' },
{ width: '0px', height: '33px', left:'-33px', top:'-33px', border: '33px solid gray', borderBottom: '0px solid transparent', borderLeft: '33px solid transparent' },
];
for(var i=0; i<4; i++){
layers[i].className = 'layer';
for(var name in styles[i]){ layers[i].style[name] = styles[i][name]; }
obj.appendChild(layers[i]);
}
}
//注册时间
obj.onmousedown = function(){ obj.style.border = '3px inset #ddd'; }
obj.onclick = function(){
if(obj.frozen){ return; }else{ obj.reset(); obj.frozen = true; }
var i = 0;
var step = 0; //执行动画
var handle = setInterval(function(){
i++;
switch(step){
case 0:
layers[0].style.borderLeftWidth = i+'px';
break;
case 1:
layers[0].style.height = i+'px';
layers[0].style.borderBottomWidth = (33-i)+'px';
break;
case 2:
layers[1].style.borderTopWidth = i+'px';
break;
case 3:
layers[1].style.width = i+'px';
layers[1].style.borderLeftWidth = (33-i)+'px';
break;
case 4:
layers[2].style.width = (33-i)+'px';
layers[2].style.borderRightWidth = i+'px';
break;
case 5:
layers[2].style.height = i+'px';
layers[2].style.borderTopWidth = (33-i)+'px';
break;
case 6:
layers[3].style.height = (33-i)+'px';
layers[3].style.borderBottomWidth = i+'px';
break;
case 7:
layers[3].style.width = i+'px';
layers[3].style.borderRightWidth = (33-i)+'px';
break;
}
if(i==33){ i=0; step++; }
if(step==8){ clearInterval(handle); obj.style.border = '3px outset #ddd'; obj.frozen = false; }
}, time/300);
}
}
window.onload=function(){
if(document.all){ document.execCommand("BackgroundImageCache", false, true); }
CoolDown(document.getElementById('btn1'), 1000);
CoolDown(document.getElementById('btn2'), 2000);
CoolDown(document.getElementById('btn3'), 4000);
CoolDown(document.getElementById('btn4'), 8000);
}
</script>

<div style="border:solid 33px #999;border-left:solid 10px #999; width:5px;height:5px; opacity: 0.7;"></div>


<div id="btn1" class="button" style="background:url(http://www.etherdream.com/funnyscript/WarIcon/Icon1.PNG);"></div>
<div id="btn2" class="button" style="background:url(http://www.etherdream.com/funnyscript/WarIcon/Icon1.PNG);"></div>
<div id="btn3" class="button" style="background:url(http://www.etherdream.com/funnyscript/WarIcon/Icon1.PNG);"></div>
<div id="btn4" class="button" style="background:url(http://www.etherdream.com/funnyscript/WarIcon/Icon1.PNG);"></div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值