with Imagination: by Dustin Diaz

./with Imagination

A JavaScript, CSS, XHTML web log focusing on usability and accessibility by Dustin Diaz

Min-height|Max-height and Min-width|Max-width Fixed!

Tuesday, March 21st, 2006

Having already known about this from the internal Y! news but not being able to blog about it until now (I totally wanted to be the first to announce this), IE7 beta2 has implemented the much anticipated css properties known as min-height, max-height, min-width, max-width. With this piece of news we can now fully rely on my old min-height fast hack trick for IE6 as it will now officially not break IE7. Whoo hoo! Today is a great day!

22 Responses to “Min-height|Max-height and Min-width|Max-width Fixed!”

  1. Nathan Smith

    This is great news, as small height corrections are the only thing I’ve ever used CSS hacks for. It’s a relief knowing all my sites won’t suddenly break after the big 7 switch.

  2. Elliot Swan

    Sweetness…

    Though I must say, I don’t quite get what the huge fuss is over hacks breaking in IE 7. IE 7 has fixed the star html bug, and I believe they said it will show child selectors. So it will ignore the hacks set for IE 6 and show the code set for FF, Safari, and Opera…For most of the things one would use hacks for, it looks like they’ve fixed. And for the rest, you can override with their conditional code.

    Right? Or have I been missing something all this time…

  3. Dustin Diaz

    They did indeed fix the * html hack, but only in standards mode. It will still work in quirks for IE7 - so beware you quirky junkies ;)

  4. Sebastian

    What about the !important hack? I always use that in relation with the min-height attribute.
    And dont forget easy clearing is out the window

  5. James Mitchell

    That is very cool. I’ll be able to start implementing it as soon as IE7 is in non-beta and the windows update “forces” people to update it. Till then - back to the hacks ;)

  6. FocusMinded.com » Fixed: Min-height|Max-height and Min-width|Max-width (IE7)

    […] quickLink: Min-Max fixed in IE7 […]

  7. xar

    yes, i´ts a great notice, but unfortunately, it does not support for :after and :before so, we will have a problem with clearing methods… :( See more in 456 bereastreet

    http://www.456bereastreet.com/archive/200603/new_clearing_method_needed_for_ie7/

  8. Gonzalo López » Internet Explorer 7 viene fuerte

    […] Al parecer la próxima versión de Internet Explorer tiene varios puntos a su favor, lo que indica que el equipo de desarrollo del navegador se está poniendo las pilas para entregar algo con calidad. Además han hecho muy bien al decidir que IE 7 no vendrá como componente de Windows Explorer en Windows Vista, y podrá reemplazar a la versión 6 incluso en máquinas con Windows XP. […]

  9. Gerald

    stop pandering to their marketing bludgeon truncheon and write some proper CSS that leaves stupid IE* in the dust.

    I am sick I have been researching a simple two column layout for three days now, which took one day to write originally, to try to make it work at least 1/2 as well in IE.

    I refuse to produce code that is not going to be viable in three years time.

    Which customer would you give filthy hack code to like the code that microsoft want you to write? I would not give IE-”compatible” CSS markup to my dog to lie on.

  10. rich

    Unfortunately, some of use MUST deal with IE6 and it’s bugs. I agree, the resulting code is not even fit for a dog to lie on, but the reality is that if my CSS breaks in IE6, then I am NOT doing my job.

    I hate it, I don’t agree with it, and I think that it is fundamentally incorrect, but when I make these arguments to my client, they suggest going back to hacky tables to control page layout.

    I am working on a huge Intranet project; even as such, there is much internal debate over standards vs. hacky code that works in IE6. I have made the argument that the standards compliant XHTML Strict 1.0 and CSS will be better for accessibility, ease maintenance, and lay a foundation for the future, including the much anticipated release of IE7. My arguments have been heard, but if I don’t make it also backwards compatible with IE6 (the ‘official’ supported browser internally) then I am out of a job.

  11. Jeremy Nicoll

    And of course we have to realize that over 70% of people use Internet Explorer. Many of these people are those who turn on their computers only to type out a paper or play a game. They have no idea what browser standards are or that IE is in fact a big piecee of junk that ought to be burned… they only know that the big E on their desktop is how they connect to the Internet. So as long as we have those people around (and we will as long as IE is the default browser in Windows), we have to put up with the bugs of the evil empire. I try to always make my code work in Firefox, and to a slightly lesser extent, Opera, so as to give people more reasons to switch instead of less. I also complain (a lot) to companies that only publish code for IE only.

  12. Andy

    Is there some example code that demonstrates how to
    use the max-height hack? I’ve tried implementing both

    height:auto;
    and
    max-height:500;

    but IE6 doesn’t appear to be consistently respecting this directive. I wonder if it has something to do with the strict document type and the parsing of the HTML code? I’m confused because some pages appear to do the right thing (adding
    scroll bars) and others ignore the max-height
    property.

  13. Lee

    Dustin, where’s the original article gone - I need to direct someone to it?

  14. Dustin Diaz

    Lee: Which original article?

  15. Lee

    Hi Dustin - I meant the original explanation article - the link in the intro text at the top of the page goes back to the home page.

  16. dzieci

    I fix it by the my own way. I’m just using fixed width ;-)

  17. dzieci

    I fix that problem by the my own way. I use fixed dimensions :-)

  18. rolety

    Yes, I use fixed dimensions too.

  19. chad lindstrom’s blog » Blog Archive » IE7

    […] Min-height|Max-height and Min-width|Max-width Fixed! @ dustindiaz.com […]

  20. kheven

    wat if users have different resolutions?

  21. Jerry

    If user have different resolution whole site are smaller.

  22. Mark

    I cant get this code to work with IE7.

    I am trying the following:
    #MasterBarContainer
    {
    min-width:600px;
    width:auto !important;

    height: 50px;
    border-width:1px;
    border-style: dotted;
    border-color:#000;
    }
    #LMasterBarContainer
    {
    float: left;
    border-width:1px;
    border-style: dotted;
    border-color:#000;
    width:200px;
    }
    #RMasterBarContainer
    {
    float: right;
    border-width:1px;
    border-style: dotted;
    border-color:#000;
    width:200px;
    }
    #MMasterBarContainer
    {
    min-width:200px;
    width:auto !important;

    border-width:1px;
    border-style: dotted;
    border-color:#000;
    }

    The reason I cant specify a width for MMasterBar is because it is used to tile an image horizontally for the width of the users browser (based on resolution).

Leave a Reply

Phone Number:

If you're about to post code in your comment, please wrap your code with the tag-combo <pre><code>. Also please escape your html entities - otherwise they will be stripped out. I recommend using postable.

Get "JavaScript Design Patterns"

"As a web developer, you'll already know that JavaScript™ is a powerful language, allowing you to add an impressive array of dynamic functionality to otherwise static web sites. But there is more power waiting to be unlocked--JavaScript is capable of full object-oriented capabilities, and by applying OOP principles, best practices, and design patterns to your code, you can make it more powerful, more efficient, and easier to work with alone or as part of a team."

Buy JS Design Patterns from Amazon.com Buy JS Design Patterns from Apress

Flickr

Submit a Prototype

All content copyright © 2003 - 2007 under the Creative Commons License. Wanna know something? Just ask.

About | Archives | Blog Search

[x] close

Loading...

Submit a prototype

By checking this prototype I agree that I am not submitting false credentials, pornography, or a hate crime website. I also understand that by submitting my entry I may or may not be accepted, and if accepted, my entry may be taken down at any given time if I violate these terms.