【问题标题】:CSS table height overflowing container div in IE8IE8中的CSS表格高度溢出容器div
【发布时间】:2017-10-08 16:09:45
【问题描述】:

我遇到了一个问题,我在父 div 中有一个动态构建的表。

我已将父 div 设置为最大高度,但如果表格更大,则表格完全忽略其父 div 的最大高度并溢出页面

以下是表格的 CSS:

#navigator_table
{   
table-layout: fixed;
font-family: Arial;
font-size: 10px;
margin: 5px 5px;
text-align: center;
border-collapse: collapse;
border: 1px solid #000;
Width: 95%;
}

以下是 div 的 CSS:

.navigator_overflow
{
max-width: 650px;
height: expression(this.scrollHeight > 599 ? "600px" : "auto");
max-height: 600px;
overflow: scroll;
   }

我已经尝试在 div 和 table 中添加以下任何结果:

overflow: hidden, auto, scroll
clear: both; 
float: left;
display: block;

overflow hidden 刚刚移除了滚动条,但表格仍然超出了页面边界。

我已经尝试添加:

height: expression(this.scrollHeight > 599 ? "600px" : "auto");
/* supposed to be the workaround for max-height in IE*/

上桌

max-height 在 Firefox 和 Chrome 中效果很好。这只是 IE

我正在使用以下文档类型:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

对此的任何帮助将不胜感激。

【问题讨论】:

    标签: html css internet-explorer-8 css-tables


    【解决方案1】:

    查看这个相关问题:CSS expression to set height of div

    简短的回答,你最好使用 JavaScript 来解决这个问题......

    【讨论】:

    • 我尝试了该选项:document.getElementById('navigator_overflow').style.maxHeight = '500px'; 用于 div 和 table,但它不起作用
    【解决方案2】:

    终于找到我的答案了!


    我需要添加

    position: relative; 
    

    在父 div 中

    在以下网站中找到答案:
    http://net.tutsplus.com/tutorials/html-css-techniques/9-most-common-ie-bugs-and-how-to-fix-them/
    现在,如果有人能告诉我为什么它有效....

    【讨论】:

      猜你喜欢
      • 2016-11-05
      • 2012-02-04
      • 2011-01-11
      • 1970-01-01
      • 1970-01-01
      • 2011-09-29
      • 2013-08-17
      • 2016-07-31
      • 2014-06-10
      相关资源
      最近更新 更多