MSIE 6中的最小宽度

mmc*_*ynn 6 css internet-explorer internet-explorer-6

在Internet Explorer 6中模仿CSS属性min-width 的最终方法是什么?最好不要尝试?

kch*_*kch 8

foo { min-width: 100px }      // for everyone
* html foo { width: 100px }   // just for IE
Run Code Online (Sandbox Code Playgroud)

(或使用条件注释向IE提供单独的样式表)

  • Prestaul,IE6将宽度视为最小宽度. (2认同)

Pre*_*aul 7

您可以使用表达式(如HBoss建议的那样),但如果您担心性能,那么最好的方法是在要应用最小宽度的元素内添加垫片.

<div id="container">
  The "shim" div will hold the container div open to at least 500px!
  You should be able to put it anywhere in the container div.
  <div class="shim">&nbsp;</div>
</div>

#container .shim {
  width: 500px;
  height: 0;
  line-height: 0;
}
Run Code Online (Sandbox Code Playgroud)

这需要一些非语义标记,但它是一个真正的跨浏览器解决方案,不需要使用表达式的开销.