开发者社区> 问答> 正文

html乱码

今天在写页面时。前一秒还好好的,再刷新一下就乱码了

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        #div1{
            width: 150px;
            height: 200px;
            background-color: green;
            position: absolute;
            left: -150px;
        }
        #div1 span{
            width: 20px;
            height: 60px;
            line-height: 20px;
            background-color: blue;
            position: absolute;
            right: -20px;
            top: 70px;

        }
    </style>
    <script>
         window.onload=function(){
             var mydiv1=document.getElementById('div1');
             mydiv1.onmouseover=function(){
                 startmove(0);
             };
             mydiv1.onmouseout=function(){
                 startmove(-150);
             }
         }
         var timer=null;
         function startmove(itarget){
             var mydiv1=document.getElementById('div1');
             var speed=0;
             if(mydiv1.offsetLeft>itarget)
             {
                 speed=-10;
             }
             else
             {
                 speed=10;
             }
             clearInterval(timer);
             timer=setInterval(function(){
                 if(mydiv1.offsetLeft==itarget)
                 {
                     clearInterval(timer);
                 }
                 else{
                     mydiv1.style.left=mydiv1.offsetLeft+speed+'px';
                 }
             }, 30);
         }
         
    </script>
</head>

<body>
    <div id="div1">
        <span>分享到</span>
    </div>
</body>
<html>

展开
收起
杨冬芳 2016-06-17 13:57:30 1989 0
1 条回答
写回答
取消 提交回答
  • IT从业

    screenshot

    2019-07-17 19:42:34
    赞同 展开评论 打赏
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
《零基础HTML入门教程》 立即下载
天猫 HTML5 互动技术实践 立即下载
天猫HTML5互动技术实践 立即下载