<DIV id="a_1" style="border: 2px solid #00FF00;">
<DIV id="b" style="border: 2px solid #00FFFF;">
<DIV id="a_001" style="border: 2px solid #990033" ></DIV>
</DIV>
<DIV class="b" id="h" style="border: 2px solid #CCFF00; left: 1050px; width: 45px ">
<IMG id="imgOpen" alt="右上角浮动或右上角定位" src="images/a.gif" border=2>
</DIV>
</DIV><STYLE type="text/css">
.b{position:relative;text-align:right;top:0px;padding-right:0px;}
</STYLE>如何设置css或者js能使id=h的div框一直悬浮或者定位(定在那不动)在id=a_1的div框的右上角,因为在id=h的div框中可能添加更多的图片和div以及数据等,这个悬浮或者定位是要在谷歌浏览器中显示的,请各位大神帮下小弟,谢谢了。最好能悬浮起来,谢谢了

解决方案 »

  1.   

     
    <!doctype html>
    <html dir="ltr" lang="zh-CN">
      <head>
        <meta charset="utf-8"/>
        <title>CSS Position Fixed for IE6</title>
        <style>
    * html,* html body   {background-image:url(about:blank);background-attachment:fixed;}
    * html .fixed-top    {position:absolute;bottom:auto; top:expression(eval(document.documentElement.scrollTop +(document.documentElement.clientHeight-this.offsetHeight)/2 ));}
    * html .fixed-right  {position:absolute;right:0px;left:auto;}
    * html .fixed-bottom {position:absolute;bottom:auto;top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));}
    * html .fixed-left   {position:absolute;right:auto;left:expression(eval(document.documentElement.scrollLeft));}
    .fixed-bottom  {
      position:fixed;
      left:0px;
      bottom:20px;
      background:aqua;
      width:200px;
      height:200px;
    }
    .fixed-right{
      position:fixed;
      right:0px;
      left:auto;
      top:200px;
      top:expression(eval(document.documentElement.scrollTop +(document.documentElement.clientHeight-this.offsetHeight)/2 ));
      background:red;
      width:200px;
      height:200px;
    }
    .fixed-top{
      position:fixed;
      top:0px;
      left:0px;
      background:blue;
      width:200px;
      height:200px;
    }
        </style>  </head>
      <body>
      <div style='height:2000px;width:500px;margin:10px auto; border:1px solid red;'></div>
       <div class="fixed-top"></div>
        <div class="fixed-bottom"></div>
         <div class="fixed-right"></div>
        
      
      </body>
    </html>
      

  2.   

    这个我放进div中就不好使了,请问能不能帮我写个在div中的,谢谢,就用我上面的div,谢谢了
      

  3.   

    要让div固定,设置position:fixed就行,悬浮?不懂,是始终显示在最上层的意思么?那设置z-index属性,我觉得1楼写的东西挺有帮助的,你有时间应该仔细看看
    要让h一直在a_1右下角,你也得设置a_1的position<DIV class="b" id="h" style="border: 2px solid #CCFF00;position:fixed; right:0px; width: 45px ;">
    <IMG id="imgOpen" alt="右上角浮动或右上角定位" src="images/a.gif" border=2>
    </DIV>
      

  4.   

    fixed这个属性对FF好象无效果!
      

  5.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>divPosition.html</title>

        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="this is my page">
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <style type="text/css">
        div {
        width: 100px;
        height: 100px;
        position: absolute;
        z-index: 999;
        border: 1px solid block;
        }
        #div1 {
        top: 0;
        left: 0;
        }
       
        #div2 {
        right: 0;
        bottom: 0;
        }
        </style>  </head>
      
      <body>
        <div id="div1">
         aabc
        </div>
        <div id="div2">
         aabcaaaaaaaaaa
        </div>
      </body>
    </html>