zoukankan      html  css  js  c++  java
  • 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下的正常样式:

  • 相关阅读:
    Java之List使用方法
    Java之数组遍历
    收集关于前端的一些网站、博客资源、框架、源码等 、 会持续更新哦!!!!!
    css常用代码含义
    css两列等高布局
    HTML之DocType的几种类型
    CSS实现圆角的方法
    IE6图片元素img下出现多余空白问题
    web标准常见问题整理
    好的 Web 前端年薪会有多少?
  • 原文地址:https://www.cnblogs.com/ninestates/p/2658246.html
Copyright © 2011-2022 走看看