【问题标题】:Div Height not working with Dynamic Content IEdiv 高度不适用于动态内容 IE
【发布时间】:2012-10-13 02:21:26
【问题描述】:

我有一个脚本可以将谷歌图表 api 信息加载到一个 div 中。 div 具有固定的高度和滚动属性。但是,当来自谷歌的表格加载时,它会溢出 div(见下图)。这是在IE 8兼容模式下,css如下:

div.dashwrapper .no_overflow{overflow-x: hidden; overflow-y: scroll; height: 300px;}

这是它在 IE8 中的样子(蓝色轮廓来自开发人员工具,但它勾勒出 div 的高度)

这就是它在 Firefox 中的样子(它应该是什么样子)

这里是它的 HTML/Javascript:

<script>
var table = new google.visualization.Table(document.getElementById('chain_info_this_year'));
    table.draw(data , {showRowNumber: true});

    data = new google.visualization.DataTable();
    data.addColumn('string', 'Store Name');
    data.addColumn('string', 'Chain');
    data.addColumn('number', 'Intakes <?php echo date("F");?>');
    data.addColumn('number', 'Ships <?php echo date("F");?>');
    data.addColumn('number', 'Intakes <?php echo date("Y");?>');
    data.addColumn('number', 'Ships <?php echo date("Y");?>');
    data.addRows([
                <?php 
                for ($i = 0; $i < count($store_info); $i++)
                {
                    
                    if ($i <count($store_info) - 1)
                        echo "['" . str_replace("'", '',$store_info[$i]['chain']) . "', '" . str_replace("'", '', $store_info[$i]['store']). "', "  . $store_info[$i]['intakes_this_month'] . "," 
                            . $store_info[$i]['ships_this_month'] . "," . $store_info[$i]['intakes_this_year'] . "," . $store_info[$i]['ships_this_year'] . "],";   
                    else 
                        echo "['" . str_replace("'", '',$store_info[$i]['chain']) . "', '" . str_replace("'", '', $store_info[$i]['store']). "', "  . $store_info[$i]['intakes_this_month'] . "," 
                                . $store_info[$i]['ships_this_month'] . "," . $store_info[$i]['intakes_this_year'] . "," . $store_info[$i]['ships_this_year'] . "]";
                }
                ?>
                ]);
            var table = new google.visualization.Table(document.getElementById('store_info'));
    table.draw(data , {showRowNumber: true});

    </script>
    <div class='dash_row no_overflow'>
    <div class='dash_mod full_width'>
        <div class='title'>Store Information <span class='small_text space_left'><a style='cursor: pointer' onclick = "expand();">Show All</a></span></div>
        <div class='mod_content'><span id='store_info'></span></div>
    </div>
</div>

还有更多的 html,但这是相关的东西。 dash_row div 在 dashwrapper 内部,只是为了澄清。

更新:JSFiddle 链接:http://jsfiddle.net/qKzLf/

【问题讨论】:

  • 请提供html代码
  • 只会是“溢出:隐藏;”在包含的 div 上工作?
  • 请提供代码示例。以jsfiddle.net 为例
  • 感谢帮助,HTML已添加。 @Mike,溢出:隐藏不起作用,因为我需要能够滚动整个表格。它与 IE 忽略动态生成内容的高度属性有关。例如,创建 div 时设置了高度,但随后插入了来自 google 图表 api 的数据并忽略了高度。
  • 这是一个示例,Charts api 无法正常工作,我必须检查并确保我复制了所有内容。不过,这非常接近。 jsfiddle.net/qKzLf

标签: html css internet-explorer cross-browser


【解决方案1】:

我找到的唯一解决方案是在内容加载后使用 JQuery 重置 CSS 高度属性。这是因为,显然,兼容模式下的 IE 8 会渲染 css,然后使用动态内容忽略它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-09-15
    • 2016-05-12
    • 1970-01-01
    • 1970-01-01
    • 2011-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多