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下的正常样式:

posted @   11ge  阅读(533)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· [AI/GPT/综述] AI Agent的设计模式综述
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
点击右上角即可分享
微信分享提示