Sharron
2016-05-30 11:58
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>分享</title> <style type="text/css"> *{ margin:0; padding:0; } #box{ width:200px; height:122px; background:red; margin-top:100px; padding-top:78px; margin-left:-200px; } #box #share{ margin-left:200px; padding:3px; display:block; width:20px; height:44px; background:blue; color:white; border-radius:3px; } </style> <script type="text/script"> window.onload=function(){ var timer=null; var box=document.getElementById("box"); box.onmouseover=function(){ startMove(); } } function startMove(){ var box=document.getElementById("box"); setInterval(function(){ box.style.margin-left=box.offsetLeft+10+'px'; },30) } </script> </head> <body> <div id="box"> <span id="share">分享</span> </div> </body> </html>
首先是第34行改成<script type="text/javascript">
再就是,第45行,那个magin-left在js不是这么用的,而是magrinLeft.
<script type="text/script">改成<script type="text/javascript">
JS动画效果
113920 学习 · 1502 问题
相似问题
回答 2