# 怎么让它计算到整数啊?

0

`<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf8"><title>无标题文档</title><style type="text/css">*{margin:0;padding:0;}     ul,li{list-style:none}    .red{ background:red;}    .blue{ background:blue}    .wrap{width:500px;height:300px;overflow:hidden;position:relative;margin:55px auto}    .inner{position:absolute;left:0;top:0;}    .inner li{float:left;width:500px;height:300px;color:#fff}    .orange{ background:orange}    .nav{position:absolute;bottom:5px;right:5px;}    .nav li{float:left;padding:1px 4px;background:orange;border:1px solid #000;margin-right:4px}    .nav .nav_cur{background:#333;color:#fff;}    #box{ position:absolute;top:50px;left:0;z-index:88}</style><!--<script type="text/javascript" src="jquery-1.6.min.js"></script>--></head><body><div class="box" id="box">sd</div><div class="wrap">    <div class="inner" id="inner">        <ul>            <li class="red">1</li>            <li class="blue">2</li>            <li class="red">3</li>        </ul>    </div>        <div class="nav">        <li class="nav_cur">1</li>        <li>2</li>    </div></div><script type="text/javascript">    var timer;    var u=0;            function \$(id){            return document.getElementById(id)        }        var i=0;        var cur;        var arr = [0,-500,-1000];        function aa(){            if(\$("inner").offsetLeft != arr[i+1]){                u +=   parseInt((arr[i+1] + \$("inner").offsetLeft)/20);                console.log(u)                timer = setTimeout(function(){aa()},10)            }            else{                i++;                if(i ==3){                    clearInterval(cur)                }                clearTimeout(timer)            }            \$("inner").style.left = u+"px";        }                cur = setInterval(function(){        aa()        },2000)        </script></body></html>`

0

LCM | 大侠五级 |园豆：6876 | 2011-11-01 08:30

0

@深蓝色梦想:

`<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf8"><title>无标题文档</title><style type="text/css">*{margin:0;padding:0;}     ul,li{list-style:none}    .red{ background:#f00;}    .blue{ background:#00f;}    .green{background:#0f0;}    .wrap{width:500px;height:300px;overflow:hidden;position:relative;margin:55px auto}    .inner{position:absolute;left:0;top:0;float:left;}    .inner ul{width:1800px;float:left;overflow:visible;}    .inner li{float:left;width:500px;height:300px;color:#fff;display:block;}    .orange{ background:orange}    .nav{position:absolute;bottom:5px;right:5px;}    .nav li{float:left;padding:1px 4px;background:orange;border:1px solid #000;margin-right:4px}    .nav .nav_cur{background:#333;color:#fff;}    #box{ position:absolute;top:50px;left:0;z-index:88}</style><!--<script type="text/javascript" src="jquery-1.6.min.js"></script>--></head><body><div class="box" id="box">sd</div><div class="wrap">    <div class="inner" id="inner">        <ul>            <li class="red">1</li>            <li class="blue">2</li>            <li class="green">3</li>        </ul>    </div>        <div class="nav">        <li class="nav_cur">1</li>        <li>2</li>    </div></div><script type="text/javascript">    var timer;    var u=0;            function \$(id){            return document.getElementById(id)        }        var i=0;        var cur;        var arr = [0,-500,-1000];        function aa(){            if(\$("inner").offsetLeft > arr[i]){                u +=   parseInt((arr[i] + \$("inner").offsetLeft)/20);                console.log(u)                timer = setTimeout(function(){aa()},1000)            }            else{                i++;                if(i ==3){                    clearInterval(cur);                    \$("inner").offsetLeft=0;                }                clearTimeout(timer)            }            \$("inner").style.left = u+"px";        }                cur = setInterval(function(){        aa()        },1000)        </script></body></html>`

0

JeanCanDoIt | 园豆：137 (初学一级) | 2012-01-18 21:19

您需要登录以后才能回答，未注册用户请先注册