CSS - 如何使IE7的最小宽度 [英] CSS - How to make IE7 respect min-width

查看:130
本文介绍了CSS - 如何使IE7的最小宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IE7忽略了我的最小宽度设置。我读到IE7支持最小宽度,只要你在标准模式(不是怪癖)。我指定了

 <!DOCTYPE html> 

作为我的标题。标记是有效我仍然无法获得IE7以尊重 min-width 。我该怎么办?






 示例代码
$ b b< table class =ProcedureTable>
< thead>
< tr>
< th>栏资料< / th>
< th>栏资料< / th>
< th>栏资料< / th>
< th>栏资料< / th>
< th>栏资料< / th>
< / tr>
< / thead>
< tr class =PadColumns>
< td class =ExpandName>
column data
< / td>

CSS

  .ExpandName 
{
min-width:25em;
}


解决方案

in this a while ago



查看此链接



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



基本上...你需要在JS中包含这个shim来手动修改规则。





$ b

b

  / * 
作者:Rob Eberhardt
desc:fix MinWidth for IE6& IE7
params:none
返回:无
注意:还不能修复像INPUT或SELECT这样的无用的元素
history:
2006-11-20修订了标准模式兼容性
2006-11-17第一版本
* /
function fixMinWidthForIE(){
try {
if(!document.body.currentStyle){return} / IE only
} catch(e){return}
var elems = document.getElementsByTagName(*);
for(e = 0; 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;背景:
shim.style.width = l_minWidth;
shim.appendChild(document.createElement(& nbsp;));
if(elems [e] .canHaveChildren){
elems [e] .appendChild(shim);
} else {
//?
}
}
}
}

strong>有另一种方法可以做到



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); / *为IE设置最小高度* /
}


IE7 is ignoring my min-width setting. I read that IE7 supports min-width as long as you are in Standards mode (not quirks). I specified

<!DOCTYPE html>

as my header. The markup is valid. I still can't get IE7 to respect min-width. What should I do?


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;
}

解决方案

Ah Yes.. I ran into this a while ago

check out this link

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

Essentially ... you need to include this shim in JS to manually hack the rule

Below is the way that I handle it tho

Just call the function onload of the body

    /*
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{
            //??
         }
      }
   }
}

there is another way to do it as well

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 */
}

这篇关于CSS - 如何使IE7的最小宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆