c转战web

运动连续:

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js运动土豆</title>
<script src="move.js" type="text/javascript"></script>


</head>
<style>
*{
border:none;
margin:0;
padding:0;
}
a{
color:#FFF;
text-align:center;
text-decoration:none;
}
a:hover{
background:#906;
color:#FF0;
}
li{
list-style:none;
}
#div1{
display:none;
width:200px;
height:300px;
background:#000;
position:absolute;
bottom:-300px;
right:0;
}
#div2{
width:200px;
height:50px;
background:#090;
position:absolute;
bottom:0;
right:-200px;
}
#left{
height:139px;
width:34px;
float:left;
}
#left ul{
height:139px;
width:34px;
}
#left ul li{
width:34px;
height:26px;
margin-top:2px;
background:#000;
}
#weather{
background:#000;
width:160px;
height:280px;
margin-top:20px;
float:right;
}
#weather ul{
width:160px;
height:280px;
}
#weather ul .lei{
margin-top:10px;
height:60px;
background:#000;
}
.lei p{
position:relative;
top:15px;
display:block;
width:70px;
height:15px;
line-height:15px;
background:#FFF;
}
.lei img{
width:42px;
height:39px;
position:relative;
left:80px;
}
.lei em{
position:relative;
bottom:10px;
color:#0C0;
width:160px;
font-size:10px;
height:10px;
}
</style>
<script>
window.onload=function(){
var oBt=document.getElementById('obt');
var oDiv1=document.getElementById('div1');
var oDiv2=document.getElementById('div2');
oBt.onclick=function(){
startMove(oDiv2,'right',0,function(){
oDiv1.style.display='block';
startMove(oDiv1,'bottom',50);
})
}
}
</script>
<body>
<input type="button" value="运动" id="obt"  />
<div id="div1">
<div id="left">
<ul>
<li><a href="http://shop113745950.taobao.com/shop/view_shop.htm?spm=a1z0e.1.10010.4.UhaZJU">天气</a></li>
<li><a  href="http://shop113745950.taobao.com/shop/view_shop.htm?spm=a1z0e.1.10010.4.UhaZJU">星座</a></li>
<li><a  href="http://shop113745950.taobao.com/shop/view_shop.htm?spm=a1z0e.1.10010.4.UhaZJU">热点</a></li>
<li><a  href="http://shop113745950.taobao.com/shop/view_shop.htm?spm=a1z0e.1.10010.4.UhaZJU">排行</a></li>
<li><a  href="http://shop113745950.taobao.com/shop/view_shop.htm?spm=a1z0e.1.10010.4.UhaZJU">直播</a></li>
</ul>
</div>
<div id="weather">
<ul>
<p>驻马店</p>
<li class="lei">
<p>今天周五</p>
<img src="01.gif" /><br>
<em>5-20度微风小于3级</em>
</li>
<li class="lei">
<p>明天</p>
<img src="02.gif" /><br>
<em>5-20度微风小于3级</em>
</li>
<li class="lei">
<p>后天</p>
<img src="01.gif" /><br>
<em>5-20度微风小于3级</em>
</li>
</ul>
</div>
</div>
<div id="div2"></div>
</body>

</html>

运动框架:

move.js

function getStyle(obj, name)
{
if(obj.currentStyle)
{
return obj.currentStyle[name];
}
else
{
return getComputedStyle(obj, false)[name];
}
}


function startMove(obj, attr, iTarget, fnEnd)
{
clearInterval(obj.timer);
obj.timer=setInterval(function (){
var cur=0;

if(attr=='opacity')
{
cur=Math.round(parseFloat(getStyle(obj, attr))*100);
}
else
{
cur=parseInt(getStyle(obj, attr));
}

var speed=(iTarget-cur)/6;
speed=speed>0?Math.ceil(speed):Math.floor(speed);

if(cur==iTarget)
{
clearInterval(obj.timer);

if(fnEnd)fnEnd();
}
else
{
if(attr=='opacity')
{
obj.style.filter='alpha(opacity:'+(cur+speed)+')';
obj.style.opacity=(cur+speed)/100;

document.getElementById('txt1').value=obj.style.opacity;
}
else
{
obj.style[attr]=cur+speed+'px';
}
}
}, 30);
}

你可能感兴趣的:(html,js,web开发,土豆)