加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

html – CSS – 如何使IE7尊重最小宽度

发布时间:2020-12-14 21:42:44 所属栏目:资源 来源:网络整理
导读:IE7忽略了我的最小宽度设置。我读到IE7支持最小宽度,只要你处于标准模式(不是怪癖)。我指定 !DOCTYPE html 作为我的标题标记是valid.我仍然不能得到IE7尊重最小宽度。我该怎么办? Sample Code table class="ProcedureTable" thead tr thcolumn data/th thc
IE7忽略了我的最小宽度设置。我读到IE7支持最小宽度,只要你处于标准模式(不是怪癖)。我指定
<!DOCTYPE html>

作为我的标题标记是valid.我仍然不能得到IE7尊重最小宽度。我该怎么办?

Sample Code

     <table class="ProcedureTable">
        <thead>
            <tr>
                <th>column data</th>
                <th>column data</th>        
                <th>column data</th>
                <th>column data</th>
                <th>column data</th>
            </tr>
        </thead>
                    <tr class="PadColumns">
                        <td class="ExpandName">
                            column data
                        </td>

CSS

.ExpandName
{
    min-width:25em;
}

解决方法

啊是的..我曾经遇到过这样的事情

看看这个链接

http://blog.throbs.net/2006/11/17/IE7+And+MinWidth+.aspx

基本上…您需要在JS中包含这个垫片来手动地将这个规则删除

下面是我处理它的方式

只需调用身体的功能onload

/*
author: Rob Eberhardt
desc: fix MinWidth for IE6 & IE7
params: none
returns: nothing
notes: cannot yet fix childless elements like INPUT or SELECT
history:
   2006-11-20 revised for standards-mode compatibility
   2006-11-17 first version
*/
function fixMinWidthForIE(){
   try{
      if(!document.body.currentStyle){return} //IE only
   }catch(e){return}
   var elems=document.getElementsByTagName("*");
   for(e=0; e<elems.length; e++){
      var eCurStyle = elems[e].currentStyle;
      var l_minWidth = (eCurStyle.minWidth) ? eCurStyle.minWidth : eCurStyle.getAttribute("min-width"); //IE7 : IE6
      if(l_minWidth && l_minWidth != 'auto'){
         var shim = document.createElement("DIV");
         shim.style.cssText = 'margin:0 !important; padding:0 !important; border:0 !important; line-height:0 !important; height:0 !important; BACKGROUND:RED;';
         shim.style.width = l_minWidth;
         shim.appendChild(document.createElement("&nbsp;"));
         if(elems[e].canHaveChildren){
            elems[e].appendChild(shim);
         }else{
            //??
         }
      }
   }
}

还有另一种方法来做到这一点

http://perishablepress.com/press/2007/01/16/maximum-and-minimum-height-and-width-in-internet-explorer/

* html div#division { 
   height: expression( this.scrollHeight < 334 ? "333px" : "auto" ); /* sets min-height for IE */
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读