It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming CSS Forum

IE7 min-height

IE7 min-height

Postby pachelbel101 on Fri Sep 01, 2006 7:37 pm

Hello,

Before IE7 came around, I had a great solution for setting min-height in browsers that support min-height, and IE6 using a small hack. Now I'm trying to get a min height solution for IE7 and am not having much luck.

I searched the web and found a few hacks that supposedly work in 6 & 7, as well as FF, O, etc. Some of the responders said it worked great, others said "this doesn't work in IE". I did see on MANY sites that IE7 now supports the CSS property min-height but I haven't been able to get it working. Do you have to do something special that I'm not aware of? Here's the test code I wrote:

Code: Select all
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   <html>
   <head>
      <title>test</title>
      <style>
         #contentbox {
            background: #CCCCFF;
            border: 3px solid black;
            width: 400px;
            min-height: 200px;
         }
      </style>
   </head>
   <body>
      <div id="contentbox">
         <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi accumsan augue ut ante. In hac habitasse platea dictumst. Donec vitae justo eu purus scelerisque hendrerit. Integer nisi ante, volutpat at, vulputate id, ullamcorper ac, orci. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
         <!--
         <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi accumsan augue ut ante. In hac habitasse platea dictumst. Donec vitae justo eu purus scelerisque hendrerit. Integer nisi ante, volutpat at, vulputate id, ullamcorper ac, orci. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
         -->
      </div>
   </body>


With the second paragraph commented out, there should be extra space at the bottom as it's not enough to reach the minimum height. Uncommented, the box should grow to accomodate the content. Firefox does both perfectly as we all know it supports min-height. IE doesn't - the box is only as big as the content needs it to be.

Is there something I need to do to make this work that I'm not doing? Thank you for your help.
pachelbel101
 
Posts: 0
Joined: Fri Sep 01, 2006 7:24 pm

Postby johneva on Sat Sep 02, 2006 8:54 am

I carnt remember 100% now but if I remember correctly you can just set a height in IE and the div will still expand to the needed size, then use min hight for FF.

So this should work but the underscore hack wont validate and is not the correct way to do things fiffrent for each browser.

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   <html>
   <head>
      <title>test</title>
      <style>
         #contentbox {
            background: #CCCCFF;
            border: 3px solid black;
            width: 400px;
            min-height: 200px;
            _height: 200px;
           }
      </style>
   </head>
   <body>
      <div id="contentbox">
         <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi accumsan augue ut ante. In hac habitasse platea dictumst. Donec vitae justo eu purus scelerisque hendrerit. Integer nisi ante, volutpat at, vulputate id, ullamcorper ac, orci. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
        <!--
         <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi accumsan augue ut ante. In hac habitasse platea dictumst. Donec vitae justo eu purus scelerisque hendrerit. Integer nisi ante, volutpat at, vulputate id, ullamcorper ac, orci. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
         -->
      </div>
   </body>
Image
Only God Can Judge Me.
User avatar
johneva
500+ Club
 
Posts: 565
Joined: Sat Oct 29, 2005 1:16 pm
Location: Stafford, England


Who is online

Users browsing this forum: No registered users and 0 guests