IE6下绝对定位的高度自适应

  样式类似于聊天工具的resize,缩放窗口时消息区高度变化,其它元素高度不变,在chrome、FireFox下表现很好做,但IE6下不正常,消息区高度不能自适应变化。

  如下图,正常的情况和IE6下不正常的情况(灰色区是消息区),IE6下高度不是自动填充;     

     

  代码:  

<div id="dialog_chatting" class="dialog_chatting"  style="display:none;">
        <div class="chatPanel">
            <div class="revPanel">                    
            </div>
            <div class="sendPanel">
                <textarea class="txtReply"></textarea>
                <button class="btChat">发送</button>  
            </div>   
        </div>     
    </div>

  样式:

.chatPanel {height:100%; width:100%;_height:100%; _width:100%;position:relative; }
.revPanel { position:absolute; top:0; left:0; bottom:100px; right:0;width:100%;_width:100%; overflow-y:auto;word-break:break-all; background-color:#ccc;_height:expression( (this.parentElement.clientHeight -100) +'px');} 
.sendPanel {position:absolute; bottom:0; left:0; right:0; padding-top:4px; height:96px;_height:96px;  width:100%;}

 解决IE的bug办法就是这一句:  

_height:expression( (this.parentElement.clientHeight -100) +'px');

网上找了很多方法,测试了下,只有这种方法可行,虽说expression性能不好,不过兼容了IE6,也是是比较完美的方案

 最后IE6下的正常样式:

原文地址:https://www.cnblogs.com/ninestates/p/2658246.html