Results 1 to 4 of 4

Thread: can't set div max-height in IE

  1. #1
    Join Date
    Jun 2008
    Posts
    192
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default can't set div max-height in IE

    I have a div whose maximum height I'm setting as follows:

    div
    {
    max-height: 50px;
    overflow: hidden;
    }

    This makes it so that any content whose height spans beyond 50px will not be completely visible (i.e. it will overflow below the bottom border of the div where it will not be seen).

    This seems to work in Firefox but not in IE. In IE, the div still stretches beyond the height of 50px to make room for its contents such that everything is visible.

    How can I enforce the maximum height in IE?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Starting in version 7 IE supports max-height, but only if the page has a standards invoking DOCTYPE.

    If you're in standards mode, you must be testing in IE 6 or less. Or you're in quirks mode. Which is it?

    I ask because the fix is different depending upon the DOCTYPE and which mode the page is in.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    gib65 (03-13-2012)

  4. #3
    Join Date
    Jun 2008
    Posts
    192
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

    It magically started working now, so I guess the problem is solved.

  5. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Actually, that DOCTYPE is a quirks mode DOCTYPE, so perhaps you switched the mode in your browser. If that's what happened, you cannot rely upon your users to do so.

    The closest standards invoking DOCTYPE to the one listed in your post is:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    Though many prefer the more succinct HTML 5 DOCTYPE:

    Code:
    <!DOCTYPE html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •