HighDots Forums  

min-height current wisdom

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss min-height current wisdom in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jeff
 
Posts: n/a

Default min-height current wisdom - 03-19-2008 , 09:34 PM






I need to set a minimum height for a div, yet have it expand with the
contents.

I have this from 2005:

<style type="text/css">
div{
height: 12px;
background-color: red;
1px solid black;min-height:12px
}

html>body div{
height: auto; /* for not-IE */
}
</style>

<div>one<br>two</div>
<br>
<div></div>

That works in my Firefox 2.0, Opera 9 and IE6 win XP.

Is that still the current best wisdom on this task? This still works
in IE7?

Jeff

Reply With Quote
  #2  
Old   
John Hosking
 
Posts: n/a

Default Re: min-height current wisdom - 03-20-2008 , 01:22 AM






Jeff wrote:
Quote:
I need to set a minimum height for a div, yet have it expand with the
contents.

I have this from 2005:

style type="text/css"
div{
height: 12px;
background-color: red;
1px solid black;min-height:12px
Missing a border: above?

Quote:
}

html>body div{
height: auto; /* for not-IE */
More accurate: /* for IE6 and below */

Quote:
}
/style

div>one<br>two</div
br
ick

Quote:
div></div

That works in my Firefox 2.0, Opera 9 and IE6 win XP.

Is that still the current best wisdom on this task? This still works
in IE7?
No. See "html > body" child selector filter (and the rest of the page)
at http://msdn2.microsoft.com/en-us/library/bb250496.aspx


--
John
Read about the UIP: http://improve-usenet.org/


Reply With Quote
  #3  
Old   
Jeff
 
Posts: n/a

Default Re: min-height current wisdom - 03-20-2008 , 03:46 AM



John Hosking wrote:
Quote:
Jeff wrote:
I need to set a minimum height for a div, yet have it expand with the
contents.

I have this from 2005:

style type="text/css"
div{
height: 12px;
background-color: red;
1px solid black;min-height:12px

Missing a border: above?

Yeah, I meant to chop the entire line.
Quote:
}

html>body div{
height: auto; /* for not-IE */

More accurate: /* for IE6 and below */

}
/style

div>one<br>two</div
br

ick
Well that's as simple as I could make it.
Quote:
div></div

That works in my Firefox 2.0, Opera 9 and IE6 win XP.

Is that still the current best wisdom on this task? This still works
in IE7?

No. See "html > body" child selector filter (and the rest of the page)
at http://msdn2.microsoft.com/en-us/library/bb250496.aspx
Is there a "solution" to the div min height issue? What I actually
have is rows of different colored divs (in a table) with varying number
of lines in them. If I don't set a height I don't have a color sample.
If I set a height then the text might flow below the div. I don't want
to stuff &nbsp;'s in them.

I suppose I could add a rule using javascript, but that's more of a
hack than the above hack. I hate CSS hacks as time always seems to
break them.

Jeff


Quote:


Reply With Quote
  #4  
Old   
David Stone
 
Posts: n/a

Default Re: min-height current wisdom - 03-20-2008 , 06:30 AM



In article <13u492cs8sk8d81 (AT) corp (DOT) supernews.com>,
Jeff <jeff (AT) spam_me_not (DOT) com> wrote:

Quote:
John Hosking wrote:
[snip]

Is there a "solution" to the div min height issue? What I actually
have is rows of different colored divs (in a table) with varying number
of lines in them. If I don't set a height I don't have a color sample.
If I set a height then the text might flow below the div. I don't want
to stuff &nbsp;'s in them.
I had thought that IE7 had implemented min-height? IIRC, it does
have min-width and max-width implemented, although you have to be
sure IE7 doesn't stumble into quirks mode...


Reply With Quote
  #5  
Old   
Bergamot
 
Posts: n/a

Default Re: min-height current wisdom - 03-20-2008 , 07:04 AM



Jeff wrote:
Quote:
I need to set a minimum height for a div, yet have it expand with the
contents.

What I actually
have is rows of different colored divs (in a table) with varying number
of lines in them.
OK...

Quote:
If I don't set a height I don't have a color sample.
Sounds like you decided on a solution (min-height) without fully
describing the problem, hence you may be fixing the wrong thing.

Post a URL, or at least a mockup showing your data in context. Then we
may be able to show you a better way to approach it.

--
Berg


Reply With Quote
  #6  
Old   
Jeff
 
Posts: n/a

Default Re: min-height current wisdom - 03-20-2008 , 10:34 AM



David Stone wrote:
Quote:
In article <13u492cs8sk8d81 (AT) corp (DOT) supernews.com>,
Jeff <jeff (AT) spam_me_not (DOT) com> wrote:

John Hosking wrote:
[snip]
Is there a "solution" to the div min height issue? What I actually
have is rows of different colored divs (in a table) with varying number
of lines in them. If I don't set a height I don't have a color sample.
If I set a height then the text might flow below the div. I don't want
to stuff &nbsp;'s in them.

I had thought that IE7 had implemented min-height? IIRC, it does
have min-width and max-width implemented, although you have to be
sure IE7 doesn't stumble into quirks mode...

I found this, circa 2006:

http://www.dustindiaz.com/min-height-fast-hack/

selector {
min-height:500px;
height:auto !important;
height:500px;
}

That supposedly worked in IE7.

Jeff


Reply With Quote
  #7  
Old   
Jeff
 
Posts: n/a

Default Re: min-height current wisdom - 03-20-2008 , 10:38 AM



Bergamot wrote:
Quote:
Jeff wrote:
I need to set a minimum height for a div, yet have it expand with the
contents.
What I actually
have is rows of different colored divs (in a table) with varying number
of lines in them.

OK...

If I don't set a height I don't have a color sample.

Sounds like you decided on a solution (min-height) without fully
describing the problem, hence you may be fixing the wrong thing.

Post a URL, or at least a mockup showing your data in context. Then we
may be able to show you a better way to approach it.

It's my old color styler that I posted a month ago. If you don't
remember it, I'll post it without live data in it.

Jeff


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.