Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fixing height to be *at least* a certain number of pixels? 3

Status
Not open for further replies.

jisoo23

Programmer
Jan 27, 2004
192
US
Hey everyone,

This may or may not be a simple question, I'm pretty new to CSS and dabbling in it a bit. Using CSS, I created a fixed-width 2-column layout using all DIV tags and an external CSS file. The width of the entire layout is fixed, which is fine. But depending on how much material is in the content area, the height of the layout becomes variable.

The question is, is there a way to set it so that the height is at least 600px, then let it expand longer if necessary? Any suggestions are appreciated.

Thanks,
Jisoo23
 
Sure - you can use a CSS hack to do this cross-browser:

Code:
div#yourDivsId {
   min-height: 600px;
   _height: 600px;
}

The first property is for Firefox, Netscape, Safari, and other browsers that support it, the second for IE-only.

While you could just set "height" to 600px, doing so in Firefox would cause undesired behaviour for things like background colours and images whenever the content went over that.

If you need your CSS to validate, consider using IE conditional comments instead.

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
BRPS said:
If you need your CSS to validate, consider using IE conditional comments instead.
More about these are available here:

And a recent article here that was interesting if you ever wanted to use conditionals to hide content from IE:

Continuing on from Dan's suggestion, here is how you could do it using conditional comments:
Code:
<style type="text/css">
  div#yourDivsId { min-height:600px; }
</style>
<!--[if IE]>
<style type="text/css">
  div#yourDivsId { height:600px; }
</style>
<![endif]-->

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]

What is Javascript? faq216-6094
 
If you need your CSS to validate, consider using IE conditional comments instead
Or just do this, which is valid CSS and has the same effect:
Code:
div#yourDivsId {
   min-height: 600px;
}
* html div#yourDivsId {
   height: 600px;
}
Conditional comments are a pain - to use them, you have to add them to every HTML page.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Hey thanks guys, this is exactly what I needed. Stars all around! =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top