PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.info.authoring.CSS > min-height current wisdom
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
min-height current wisdom

Réponse
 
LinkBack Outils de la discussion
Vieux 20/03/2008, 03h34   #1
Jeff
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut min-height current wisdom

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
  Réponse avec citation
Vieux 20/03/2008, 07h22   #2
John Hosking
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: min-height current wisdom

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?

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


More accurate: /* for IE6 and below */

> }
> </style>
>
> <div>one<br>two</div>
> <br>


ick

> <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/
  Réponse avec citation
Vieux 20/03/2008, 09h46   #3
Jeff
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: min-height current wisdom

John Hosking wrote:
> 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.
>> }
>>
>> 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.
>
>> <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


>
>

  Réponse avec citation
Vieux 20/03/2008, 13h04   #4
Bergamot
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: min-height current wisdom

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.

--
Berg
  Réponse avec citation
Vieux 20/03/2008, 16h34   #5
Jeff
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: min-height current wisdom

David Stone wrote:
> In article <13u492cs8sk8d81@corp.supernews.com>,
> Jeff <jeff@spam_me_not.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
  Réponse avec citation
Vieux 20/03/2008, 16h38   #6
Jeff
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: min-height current wisdom

Bergamot wrote:
> 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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h27.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,15067 seconds with 14 queries