4

Header, footer and sidebars have fixed position. In the center a content area with both scroll bars. No outer scroll bars on the browser. I have a layout that works in IE7 and FF. I need to add IE6 support. How can I make this work?

Here is an approximation of my current CSS.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    
    <head>
      <title>Layout</title>
      <style>
        * {
          margin: 0px;
          padding: 0px;
          border: 0px;
        }
        
        .sample-border {
          border: 1px solid black;
        }
        
        #header {
          position: absolute;
          top: 0px;
          left: 0px;
          right: 0px;
          height: 60px;
        }
        
        #left-sidebar {
          position: absolute;
          top: 65px;
          left: 0px;
          width: 220px;
          bottom: 110px;
        }
        
        #right-sidebar {
          position: absolute;
          top: 65px;
          right: 0px;
          width: 200px;
          bottom: 110px;
        }
        
        #footer {
          position: absolute;
          bottom: 0px;
          left: 0px;
          right: 0px;
          height: 105px;
        }
        
        @media screen {
          #content {
            position: absolute;
            top: 65px;
            left: 225px;
            bottom: 110px;
            right: 205px;
            overflow: auto;
          }
          body #left-sidebar,
          body #right-sidebar,
          body #header,
          body #footer,
          body #content {
            position: fixed;
          }
        }
      </style>
    </head>
    
    <body>
      <div id="header" class="sample-border"></div>
      <div id="left-sidebar" class="sample-border"></div>
      <div id="right-sidebar" class="sample-border"></div>
      <div id="content" class="sample-border"><img src="/broken.gif" style="display: block; width: 3000px; height: 3000px;" /></div>
      <div id="footer" class="sample-border"></div>
    </body>
    
    </html>
4

5 に答える 5

5

Might be overkill for your project, but Dean Edwards' IE7 javascript adds support for fixed positioning to IE6.

于 2008-08-27T14:56:46.193 に答える
1

次のコードを<head>

<!--[if lte IE 6]>
<style type="text/css">
html, body {
    height: 100%;
    overflow: auto;
}
.ie6fixed {
    position: absolute;
}
</style>
<![endif]-->

ie6fixedなりたいものにCSSクラスを追加しますposition: fixed;

于 2008-08-27T19:12:40.977 に答える
0

以下の純粋な css ハックをチェックしてください... 強制的に quirks モードにする必要があるものもあります (それが最も堅牢だと思います) が、すべてうまく機能します:

http://ryanfait.com/resources/fixed-positioning-in-internet-explorer/ http://tagsoup.com/cookbook/css/fixed/

私はこれを非常に効果的に使用しました。

于 2009-05-15T03:20:22.607 に答える
0

これらの回答は役に立ち、限られた形式の固定配置を IE6 に追加することができました。私が必要とする行動)。

上と下は指定できないので、上と高さを使いました。高さのプロパティは非常に必要であることが判明しました。ページの読み込み時とサイズ変更時に高さを再計算するために JavaScript を使用しました。

以下は、テストケースを機能させるために追加したコードです。これは、jQuery を使用すると、よりクリーンになる可能性があります。

<!--[if lt IE 7]>
<style>
body>div.ie6-autoheight {
  height: 455px;
}
body>div.ie6-autowidth {
  right: ;
  width: 530px;
}
</style>
<script src="http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE7.js" type="text/javascript"></script>
<script type="text/javascript">

function fixLayout() {
   if (document.documentElement.offsetWidth) {
      var w = document.documentElement.offsetWidth - 450;
      var h = document.documentElement.offsetHeight - 175;
      var l = document.getElementById('left-sidebar');
      var r = document.getElementById('right-sidebar');
      var c = document.getElementById('content');

      c.style.width = w;
      c.style.height = h;
      l.style.height = h;
      r.style.height = h;
   }
}
window.onresize = fixLayout;
fixLayout();
</script>
<![endif]-->
于 2008-08-29T15:02:13.110 に答える
0

IE7.js を試してください。変更を加えることなく問題を解決する必要があります。

リンク: IE7.js

于 2008-08-27T15:17:25.117 に答える