溢出:隐藏问题Internet Explorer 7

时间:2013-02-06 12:45:51

标签: html css internet-explorer internet-explorer-7 overflow

HTML

<div class="block">
    <div class="element1">text text text text </div>
    <div class="element2">text text text text text text text text text text text text text text text text text text text text text text text text text text text text</div>
</div>

CSS

.block{
    background:#F00;
    float: left;
    height: 90px;
    padding: 0 24px 0 0;
    position: relative;
    width: 256px;
}   
.block .element1{
    color: #000;
    display: block; 
    float: left;
    font-size: 32px;
    height: 35px;
    overflow: hidden;
    padding: 25px 0 0;
    text-align: right;
    width: 100%;
}
.block .element2 {
    color: #000;
    display: block;
    float: right;
    font-size: 12px;
    height: 14px;
    line-height: 1.1;
    margin: 15px 0 0;
    max-width: 205px;
    overflow: hidden;
    padding: 0 0 0 15px;
    text-align: right;
    width: auto;
}

溢出:在element2类中隐藏attr =&gt; IE8,9,FF,Chrome,Safari,Opera没有任何问题但是如果我打开带有IE7文本的页面则不显示。添加位置:相对attr到块类(包装类)但没有任何更改(IE6 + IE7 CSS problem with overflow: hidden; - position: relative; combo)如何解决问题? http://jsfiddle.net/L5Y57/

1 个答案:

答案 0 :(得分:5)

正如我在评论中所说。

您必须将position: relative;属性添加到使用overflow: hidden

的类

你有另一个问题,因为width: auto;在类.block .element2,它已知的IE7错误,解决它将其更改为width: 100%;或任何固定宽度。

您可以在代码中查看我的修正:http://jsfiddle.net/L5Y57/2/