-
Notifications
You must be signed in to change notification settings - Fork 6
/
034-分享侧边栏.html
46 lines (45 loc) · 894 Bytes
/
034-分享侧边栏.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
#div1{ width:100px; height:200px; position:absolute; background:red; left:-100px;}
#div1 span{ width:20px; height:60px;line-height:20px;text-align:center;background:yellow;left:100px; top:70px; position:absolute;}
</style>
<script>
window.onload = function()
{
var oDiv1 = document.getElementById("div1");
oDiv1.onmouseover = function()
{
startMove(10,0);
}
oDiv1.onmouseout = function()
{
startMove(-10,-100);
}
}
var timer = null;
function startMove(speed,iTarget)
{
var oDiv1 = document.getElementById("div1");
clearInterval(timer);
timer = setInterval(function(){
if(oDiv1.offsetLeft == iTarget)
{
clearInterval(timer);
}else
{
oDiv1.style.left = oDiv1.offsetLeft + speed + "px";
}
},30);
}
</script>
</head>
<body>
<div id="div1">
<span>分享到</span>
</div>
</body>
</html>