日期:2014-05-16 浏览次数:20419 次
<html>
<head>
<meta charset="utf-8">
<title>仿百度百科</title>
<style>
*{margin:0; padding:0;}
body{background:#ecf5fc;}
i,em{padding-right:3px;}
#wrap{width:740px; height:240px; position:relative; margin:0 auto; background:url(images/br.jpg) no-repeat;}
.supply{width:78px; height:181px; position:absolute; left:-78px; background:url(images/bg_l.jpg) no-repeat;}
.usersum{position:absolute; top:165px; left:33px; font-size:14px; color:#7e878c; width:539px; height:35px;}
.usersum em{float:left; margin-top:12px; font-style:normal; color:#7e878c;}
.usersum user{float:left; margin:0 10px;}
.usersum entry{float:left; margin:0 10px;}
.usersum .number{float:left; width:24px; height:35px; background:url(images/number.png) 0px 0px no-repeat; margin:0 1px 0 0;}
.usersum .comma{background:url(images/number.png) -18px -350px no-repeat; width:6px; height:7px;margin:28px 1px 0 0; overflow: hidden; float:left;}
</style>
<script>
function getByClass(oParent,sClass)
{
var aEle=oParent.getElementsByTagName("*");
var aResult=[];
var re=new RegExp("\\b"+sClass+"\\b");
for(var i=0;i<aEle.length;i++)
{
if(re.test(aEle[i].className))
{
aResult.push(aEle[i]);
}
}
return aResult;
}
function getStyle(obj,name)
{
if(obj.currentStyle)
{
return obj.currentStyle[name];
}
else
{
//对火狐下取backgroundPositioY的值特别处理一下
if(name=="backgroundPositionX")
{
if(window.navigator.userAgent.indexOf("Firefox")!=-1)//火狐
{
return parseInt(getComputedStyle(obj,false).backgroundPosition);
}
else
{
return getComputedStyle(obj,false)[name];
}
}
else if(name=="backgroundPositionY")
{
if(window.navigator.userAgent.indexOf("Firefox")!=-1)//火狐
{
return getComputedStyle(obj,false).backgroundPosition.split(" ")[1];
}
else
{
return getComputedStyle(obj,false)[name];
}
}
else
{
return getComputedStyle(obj,false)[name];
}
}
}
function startMove(obj,json,interval,type,fnEnd)
{
var stressSpeed=0;
var pattern={};
for(var attr in json)
{
pattern[attr]=parseInt(getStyle(obj,attr));
}
clearInterval(obj.timer);
obj.timer=setInterval(function(){
var bEnd=true;
for(var attr in json)
{
switch(type)
{
case "stress":
stressSpeed+=(json[attr]-pattern[attr])/10;
stressSpeed*=0.75;
pattern[attr]+=stressSpeed;
obj.style[attr]=pattern[attr]+"px";
if(Math.abs(pattern[attr]-json[attr])>0.1&&Math.abs(stressSpeed)>0.1)
{
bEnd=false;
}
break;
case "buffer":
var cur=0;
if(attr=="opacity")
{
cur=Math.round(parseFloat(getStyle(obj,attr))*100);
}
else
{
cur=parseInt