0

我的代码中有浏览器位置问题。它在 firefox 上显示良好。但在面板 div.pls 下的资源管理器内容 div 显示上,请帮助我修复此错误。

这是CSS代码

<style>
#colleft   { width:175px;float:left; overflow:hidden; background:#333;}
#showPanel { position:inherit; z-index:2; left:0; float:left; padding-top:40px; display:none; width:0px; height:100px; cursor:pointer;}
#showPanel span{display:block; font-size:24px; height:30px; margin-top:20px; padding:10px 0 10px 10px; width:20px; background: #333;}
#colright {color:#1c1c1c; margin-left:175px}
</style>

这是我的jQuery代码

<script type="text/javascript">
jQuery(document).ready(function(){
 $("#hidePanel").click(function(){
 $("#panel").animate({marginLeft:"-175px"}, 0 );
 $("#colleft").animate({width:"0px", opacity:0}, 0 );
 $("#showPanel").show("normal").animate({width:"0px", opacity:1}, 0);
 $("#colright").animate({marginLeft:"0px"}, 0);
 });
 $("#showPanel").click(function(){
 $("#colright").animate({marginLeft:"0px"}, 0);
 $("#panel").animate({marginLeft:"0px"}, 0 );
 $("#colleft").animate({width:"175px", opacity:1}, 400 );
 $("#showPanel").animate({width:"0px", opacity:0}, 600).hide("slow");
 });
});
</script>

html代码

   <table width="1024" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#999999">
      <tr>
        <td><h1>HEADER GOES HERE</h1></td>
      </tr>
      <tr>
        <td><div id="colleft">
      <div id="panel">
      <h1>My Panel</h1>
      <ul>
        <li>item #1</li>
        <li>item #2</li>
        <li>item #3</li>
        <li>item #4</li>
      </ul>
      <div id="hidePanel"><a href="#">&laquo; Hide Panel</a></div>
      </div>
      </div>
      <div id="showPanel"><span>&raquo;</span></div>  <div id="colright">
        <table width="100%" cellpadding="0" cellspacing="0" bgcolor="#0066CC">
          <tr>
            <td>content div</td></tr>
        </table></div></td>
      </tr>
      <tr>
        <td><h4>Footer goes here</</td>
      </tr>
    </table>
4

2 回答 2

0

你能详细说明它没有按照你想要的方式工作吗?javascript中的边距并不是真正相互一致的,如果你把它改成这样:

<script type="text/javascript">
            jQuery(document).ready(function(){  
                $("#hidePanel").click(function(){  
                    $("#panel").animate({marginLeft:"-175px"}, 500 );  
                    $("#colleft").animate({width:"0px", opacity:0}, 400 );  
                    $("#showPanel").show("normal").animate({width:"28px", opacity:1}, 200);  
                    $("#colright").animate({marginLeft:"50px"}, 500);  });  
                    $("#showPanel").click(function(){  
                    $("#colright").animate({marginLeft:"200px"}, 200);  
                    $("#panel").animate({marginLeft:"0px"}, 400 );  
                    $("#colleft").animate({width:"175px", opacity:1}, 400 );  
                    $("#showPanel").animate({width:"0px", opacity:0}, 600).hide("slow");  
                }); 
            }); 
    </script> 

侧面有一个小按钮,如果单击它,面板中的内容会从左侧移入,将面板中的内容向右推。

在不相关的注释中,我还注意到您使用表格来分隔页眉、内容和页脚。它不会帮助你解决这个问题,但它被认为是不好的做法。最好用 CSS 将它们分开。

于 2012-06-15T09:11:49.423 回答
0

hidePanel DIV 在面板 DIV 内,但 showPanel DIV 在面板 DIV 外。你确定这是正确的吗?

于 2012-06-15T07:04:42.223 回答