Forum Moderators: not2easy

Message Too Old, No Replies

Div Height question

Can i set a pixel value and auto?

         

Demaestro

7:58 pm on Aug 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hey,

I have a div and I have given it a value height of 850px;

I have created a couple pages that go beyond the 850px;

I would like the div to auto the height if greater then 850px;

I tried:

height:850px auto;

but that didn't work... I did a search but can't find anything. Any insight would be greatly appreciated.

Gibble

8:11 pm on Aug 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is a min-height css property, but it's not fully supported (ie 7 does though I believe).

The work around is to create a 1 px hidden div along the right edge that pushes your box open to 850 px, and still allows your content to expand beyond that.

Do a search for css min height hack and you'll stumble upon several examples of how to do it.

[edited by: Gibble at 8:12 pm (utc) on Aug. 2, 2007]

Demaestro

8:41 pm on Aug 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks Gibble that works out well.

Funny that we still have to resort to tricks like this for something that should be a logical expression.

height:850px auto

Looks nice anyway... **sigh maybe one day.

Gibble

8:47 pm on Aug 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Like I said, we have min-height, which is what you want. And it is supported by the newest browsers, we just have to wait for the latest browsers to become the norm (when they're outdated :p)

Xapti

12:27 am on Aug 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



IE6 is about the only browser I know of which doesn't support it. There's a javascript compilation called IE7.js which fixes most of IE6s bugs and rendering problems, and makes it much more compliant behavior. If you use that script, you could then use min-height without the workaround.

The workaround is pretty efficent and non-problematic though, so you don't really need that if that's t he only thing you want.

Gibble

2:13 pm on Aug 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Xapti, that's interesting, I had never heard of that js, I'll have to look into it.