Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Min-width in MSIE 6

What is the definitive way to mimic the CSS property min-width in Internet Explorer 6? Is it better not to try?

like image 585
mmcglynn Avatar asked Sep 18 '08 14:09

mmcglynn


2 Answers

foo { min-width: 100px }      // for everyone
* html foo { width: 100px }   // just for IE

(or serve a separate stylesheet to IE using conditional comments)

like image 62
kch Avatar answered Sep 22 '22 19:09

kch


You could use an expression (as suggested by HBoss), but if you are worried about performance then the best way to do this is to add a shim inside the element you want to apply a min-width to.

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

This requires a little non-semantic markup but is a truly cross-browser solution and doesn't require the overhead of using an expression.

like image 35
Prestaul Avatar answered Sep 25 '22 19:09

Prestaul