DIV with overflow:auto and a 100% wide table

前端 未结 8 1305
不思量自难忘°
不思量自难忘° 2021-01-30 03:23

I hope someone might be able to help me here. I\'ve tried to simplify my example as best I can.

I have an absolutely positioned DIV, which for this example I\'ve made fi

相关标签:
8条回答
  • 2021-01-30 03:46

    Okay, this one plagued me for a LONG time. I have made far too many designs that have extra padding on the right, allowing for IEs complete disregard for their own scrollbar.

    The answer is: nest two divs, give them both hasLayout, set the inner one to overflow.

    <!-- zoom: 1 is a proprietary IE property.  It doesn't really do anything here, except give hasLayout -->
    
    <div style="zoom: 1;">
       <div style="zoom: 1; overflow: auto">
          <table style="width: 100%"...
          ...
          </table>
       </div>
    </div>
    

    http://www.satzansatz.de/cssd/onhavinglayout.html
    Go there to read more about having layout

    0 讨论(0)
  • 2021-01-30 03:59

    This is reported fixed in GWT trunk.

    0 讨论(0)
  • 2021-01-30 04:02

    I had a problem with excessive horizonal bar in IE7. I've used D Carter's solution slighty changed

    <div style="zoom: 1; overflow: auto;">
       <div id="myDiv" style="zoom: 1;">
          <table style="width: 100%"...
          ...
          </table>
       </div>
    </div>
    

    To work in IE browser lesser than 7 you need add:

    <!--[if lt IE 7]><style> #myDiv { overflow: auto; } </style><![endif]-->
    
    0 讨论(0)
  • 2021-01-30 04:06

    Change:

    overflow: auto;
    

    to:

    overflow-y:hidden;
    overflow-x:auto;
    
    0 讨论(0)
  • 2021-01-30 04:06

    This looks like it should fix your problem, as long as you are not apposed to condition statements. Fixing IE overflow

    0 讨论(0)
  • 2021-01-30 04:13

    Eran Galperin's solution fails to account for the fact that simply turning off horizontal scrolling will still allow the table to underlap the vertical scrollbar. I assume this is because IE is calculating the meaning of "100%" before deciding that it needs a vertical scrollbar, then failing to re-adjust for the remaining horizontal space available.

    cetnar's solution above nails it, though:

    <div style="zoom: 1; overflow: auto;">
       <div id="myDiv" style="zoom: 1;">
          <table style="width: 100%">
          ...
          </table>
       </div>
    </div>
    

    This works properly on IE6 and 7 in my tests. From what I can tell, the "" hack doesn't appear to actually be necessary on IE6.

    0 讨论(0)
提交回复
热议问题