<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
body,div,span{
margin: 0;
padding: 0;
}
#div1 span{
width: 20px;
height: 50px;
background: blue;
position: absolute;
left:-200px;
top: 75px;
}
</style>
<script type="text/javascript">
window.onload =function(){
var div = document.getElementById('div1')
div.onmouseover =function(){
startMove();
}
}
function startMove(){
var div = document.getElementById('div1')
setInterval(function(){
div.style.left = div.offsetLeft +10+'px'
},30)
}
</script>
</head>
<body>
<div id="div1">
<span id="share">分享</span>
</div>
</body>
</html>
style里面 少设置一个div
span是内联标签,不能设置宽高