一直摁住右方向,及下方向键后,DIV会滚出屏幕范围(在IE,SAFARI,GOOGLE浏览器上都正常),在FF和OPERA上,overflow的hidden和visible差不多,就是hidden隐藏了滚动条而已,而DIV没有滚出屏幕。望大虾帮忙解决,谢<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<META   HTTP-EQUIV="imagetoolbar"   CONTENT="no">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
html{
  overflow:hidden;
}
</style>
</head><body>
<div id="test" style=' position:absolute; left:0px;top:0px; background-color:#666666; width:400px; height:400px;'>
</div>
<script type="text/javascript" charset="utf-8">document.onkeydown= function(e){
        e=e||window.event;
        ek=e.keyCode||e.which;
        var da = document.getElementById("test"),daol = da.offsetLeft,daot = da.offsetTop|0;
        switch(ek){
                case 37:da.style.left=daol-5+"px";break;
                case 39:da.style.left=daol+5+"px";break;
                case 38:da.style.top=daot-5+"px";break;
                case 40:da.style.top=daot+5+"px";break;
                default:break;
        }
}
</script></body>
</html>

解决方案 »

  1.   

    overflow Property
    hidden
    This value indicates that the content is clipped and that no scrolling user interface should be provided to view the content outside the clipping region. 

    Setting 'overflow' to 'hidden' for the <div>, on the other hand, causes the <blockquote> to be clipped by the containing block:
     
      

  2.   

    感觉是有点奇怪,用da.style.left取左边,然后把数字调到50后可以按出去。楼主打DOTA是不是经常送一血啊... - -!
      

  3.   


    我DOTA挺不错的,所以导致编程基础就很差,呵呵,
    刚开始学WEB开发