gpt4 book ai didi

html - CSS - 如何让 IE7 遵守最小宽度

转载 作者:技术小花猫 更新时间:2023-10-29 12:11:21 25 4
gpt4 key购买 nike

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

<!DOCTYPE html>

作为我的标题。标记为 valid.我仍然无法让 IE7 遵守 min-width。我该怎么办?


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 中包含这个 shim 来手动破解规则

下面是我处理它的方式

直接调用body的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 */
}

关于html - CSS - 如何让 IE7 遵守最小宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7068967/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com