IE doesn't support min-height, need workaround

They have: 222 posts

Joined: Sep 1999

I've got an area that I need to be at least 475px high (to display the background image), but if there is extra content i want it to grow larger to fit it. For Firefox I just use

min-height: 475px;
height: auto;

and it works great, but IE doesn't support min-height so it just makes the element as high as whatever content is in there, even if that's smaller than 475px.

I've tried putting the area inside a container and setting that to 475px height and a bunch of other things but haven't been able to get it to work.

http://fadedme.com/fm_newsite/template-full.html
http://fadedme.com/fm_newsite/template-empty.html

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

this is not the best method probably, but would work. Get a 1x1 transparent gif and if the browser is IE, display it inside with a height of 475. You will have to play around where to put it so that all your regular content flows beside it, not above of below it.

-Greg

They have: 222 posts

Joined: Sep 1999

The problem I had with that was, if I do this:

IE Sucks

then it pushes the text down to below the image, but if i do this

IE Sucks

so that the text wraps, then the image doesn't force the area to be 475px high anymore.

Renegade's picture

He has: 3,022 posts

Joined: Oct 2002

Tried floating it?

Floating the image will take it out of the "flow" so, just add a "spacer" DIV at the end of your content (i.e. at the bottom of the content DIV)

Your content div will look something like this when it's empty:

<div id="content">
<img src="./images/spacer.gif" width="1" height="475" alt="" title="" id="ie-fix" />
<!-- Content goes here -->
<div class="spacer"></div>
</div>
'

And of course, the CSS for the spacer:

#ie-fix {
position:relative; /* for a fix in opera (6, I think, don't know about 7) */
float:left; /* or right */
}

.spacer {
clear:both;
height:0;
}
'

I usually use this spacer DIV trick as a work around to my "float" problems.

They have: 222 posts

Joined: Sep 1999

That worked, thanks Smiling

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.