How to make IE support min-width / max-width CSS properties?

后端 未结 3 1496
北恋
北恋 2020-12-11 01:24

Are these properties not considered standard CSS?

I\'m using something like this, which works properly on Chrome 12, FF4, Opera 11, and Safari 5, but on IE9 the min-

相关标签:
3条回答
  • 2020-12-11 02:01

    Try following code:

    #limit-size
    {
    min-width: 998px;
    width: expression(this.width < 998 ? 998: true);
    min-height: 250px;
    height: expression(this.height < 250 ? 250: true);
    }
    
    //html:
    <div id="limit-size"></div>
    
    0 讨论(0)
  • 2020-12-11 02:04

    I found that <!DOCTYPE html> was insufficient — I had to go strict:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

    0 讨论(0)
  • 2020-12-11 02:06

    If what you are saying is true, IE9 would be deviating form the spec. However, I cannot duplicate your complaint. Using your example, IE9 respects min-width if width is less than 150px per this jsfiddle.

    EDIT:

    NOTE: Quirks Mode follow different rules and does not comply with standard CSS in any browser. If you add a doctype to the page, this should resolve the problem (add: <!DOCTYPE html>).

    To expand on the issue, Quirks Mode is not standardized. There are some things that most browser implement, but new features are undefined in those defacto standards. Thus, some browsers are allowing new CSS to be used (as you have observed), but IE9 is ignoring new css values, as they have no place in Quirks Mode.

    0 讨论(0)
提交回复
热议问题