【问题标题】:In IE8 -ms-filter background disappears when height is higher than window. (when scrollbar appears)在 IE8 中,当高度高于窗口时,背景会消失。 (出现滚动条时)
【发布时间】:2013-02-19 16:21:36
【问题描述】:

在IE8中,当div高于window时,-ms-filter背景消失。在 IE7 及以下工作正常。 (我可以使用1px的透明图片,但是如果我需要使用透明色加背景图片呢)

示例代码和小提琴:

<!DOCTYPE html>
<html lang="sk">
<head>
    <meta charset="utf-8">
    <style>
        html,body{height:100%;margin:0;padding:0;}
        #one{
            float:left;
            height:100%;
            width:50%;
            background:rgba(0,0,0,0.5);
            -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#CC917C6F,endColorstr=#CC917C6F)";
            filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#CC917C6F,endColorstr=#CC917C6F);
        }
        #two{
            float:right;
            height:101%;
            width:50%;
            background:rgba(255,0,0,0.5);
            -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#CCAAAA6F,endColorstr=#CCAAAA6F)";
            filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#CCAAAA6F,endColorstr=#CCAAAA6F);
        }
    </style>
</head>
<body>
    <div id="one"></div>
    <div id="two"></div>
</body>
</html>

http://jsfiddle.net/9dmqg/4/ 谢谢。

【问题讨论】:

    标签: html css internet-explorer-8 background gradient


    【解决方案1】:

    这是因为 p 标签的高度是固定的。将固定高度设为min-height 并添加height:auto

    #one p {
         height:auto; min-height:800px;
    }
    #two p {
        height:auto; min-height:800px;
    }
    

    DEMO

    【讨论】:

    • 谢谢,但它不起作用。 (IE8) 我不是在寻找某种 clearfix。我更新了问题,发现,那个问题不是来自p,而是直接来自div。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-01
    相关资源
    最近更新 更多