侧面小广告小例子
来源:互联网 发布:软件测试方法详解 编辑:程序博客网 时间:2024/04/27 23:55
<!DOCTYPE html>
<html>
<head>
<metacharset="UTF-8">
<title></title>
<styletype="text/css">
*{
margin:0;
padding:0;
}
#div1{
width:150px;
height:300px;
background-color: red;
position:fixed;
top:50px;
left:-150px;
}
#div1span {
position:absolute;
width:20px;
height:60px;
line-height:20px;
background-color: pink;
right:-20px;
top:120px;
border-radius:0 5px5px 0;
}
</style>
</head>
<body>
<divid="div1">
<span>分享到</span>
</div>
<scripttype="text/javascript">
// 获取标签
varoDiv = document.getElementById("div1");
// 事件绑定
oDiv.onmouseover= function() {
startMove(0);
};
oDiv.onmouseout= function() {
startMove(-150);
};
// 运动函数
vartimer = null;
functionstartMove(iTarget) {
varspeed = 0;
// 判断速度的正负,控制运动的方向
if(oDiv.offsetLeft> iTarget){
speed= -10;
}else{
speed= 10;
}
// 防止多个定时器同时工作
clearInterval(timer);
timer = setInterval(function() {
// 当运动到目标位置时,停止定时器,否则继续运动
if(oDiv.offsetLeft == iTarget) {
clearInterval(timer);
} else {
oDiv.style.left= oDiv.offsetLeft + speed + 'px';
}
}, 20);
}
// 优化1 : 把速度和目标位置,当成参数传给函数
// 优化2 : 把速度干掉,判断目标点和当前位置谁大谁小
</script>
</body>
</html>
- 侧面小广告小例子
- 从一个小侧面对比各大中文搜索引擎的实力
- silverlight小广告
- 侧边小广告
- side 侧面
- 小例子
- 页面滚动小广告
- 小广告清除初试小记
- js定时小广告推送
- 小广告固定,关闭,弹出
- jsday06(window小广告)
- bzoj 5029: 贴小广告
- bzoj 5029: 贴小广告
- 【bzoj5029】贴小广告
- bzoj5029 贴小广告
- 5029: 贴小广告
- 网页侧面点击展开
- jQuery tabs侧面显示
- [WebServer] Tomcat 配置访问限制:访问白名单和访问黑名单
- SqlHelper详解
- 多物体运动
- OLEDB SqlHelper
- VB程序学习代码记录20160711
- 侧面小广告小例子
- ASP.NET 2.0 GridView控件说明
- 缓冲运动
- 匀速运动小问题
- 获取非行间样式
- 安卓中关于Shareprence
- 碰壁反弹
- 使用ASP.NET 2.0 GridView轻松操作数据
- json小用法