IE doesn't like the max-width property; alternative?

Discussion in 'CSS' started by tarponkeith, Oct 17, 2007.

  1. #1
    For some reason IE doesn't like me using max-width in a DIV...

    I found this as an alternative online:

    
    max-width:800px;
    width:expression(document.body.clientWidth > 800? "800px": "auto" );
    
    Code (markup):
    This raises the javascript alert though... Does anyone know of a way to use min-width and max-width in IE without javascript?

    Thanks guys...
     
    tarponkeith, Oct 17, 2007 IP
  2. Alexander the Great

    Alexander the Great Peon

    Messages:
    253
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What version of IE?
     
    Alexander the Great, Oct 17, 2007 IP
  3. tarponkeith

    tarponkeith Well-Known Member

    Messages:
    4,758
    Likes Received:
    279
    Best Answers:
    0
    Trophy Points:
    180
    #3
    I'm using IE 6.0.2800.1106 ...
     
    tarponkeith, Oct 17, 2007 IP
  4. naif

    naif Well-Known Member

    Messages:
    468
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    118
    #4
    IE < 7 doesnt have support for max-width or min-width property. Or even for max-height or min-height for that matter.

    Expressions should work fine. As far as alerts are concerned, they are raised only when you try opening a page locally which contains javascript code.

    Regards,
    -- Naif
     
    naif, Oct 17, 2007 IP
  5. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #5
    As naif said, Internet Explorer 5.x and 6 don't support min/max-width/height (though they will treat height as min-height unless you force its proper behavior using overflow: hidden), so you will have to use an expression or an external JavaScript function that gets served only to Internet Explorer ( using if(document.all && document.getElementByID()) { } ) won't cut it, since some browsers such as Opera when identifying or masking itself as IE as well as Konqueror can understand document.all).

    When using an expression though, it's best to serve it separately to Internet Explorer 6 either through the Star HTML hack ( * html #selector ) or via a separate stylesheet served by a conditional comment.
     
    Dan Schulz, Oct 17, 2007 IP
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #6
    deathshadow, Oct 18, 2007 IP