Posted By

jonhenshaw on 12/31/69


Tagged

fix css ie minheight


Versions (?)



Who likes this?

289 people have marked this snippet as a favorite


tylerhall
daniel
Roshambo
luxuryluke
jamesmcoats
designerd
talaris
rdmey
samuraicoder
sendoa
panatlantica
dertimbo
kgosser
fatihturan
millisami
markfavazza
px
hxseven
zensir
imbuez
oronm
ttscoff
visualAesthetic
kemo
Hirmine
block
dmarten
basicmagic
noname
Sahoglu
clapfouine
tavo
noah
KilgoreTrout67
miyazima
icarus
nankoweap
shellydennison
lamy
cmslounge
duandan
cynic68
joseluis
Mikker
hollowmyth
manub
m10
fael
robotoverlord
rich13
marcoba
marcio
asimovi
SamuelMiller
aziz
jorgenskogmo
cubit
udayrayala
b00gertoad
m-alo
gasface
saiko
sjaq
kgl
Mithun
Winkyboy
torkil
jfherring
celoria
sp1r1t
adix
willgarrison
kaiser79
noebarnabas
visuallyspun
tome2k
KurveMedia
lzyy
axoplasm
SpinZ
snucko
seekup00
ernscht
ido
usgraphicscom
stphnclysmth
sosof
Wizzle
wbowers
danbair
mb
zeljkoprsa
rovision
jamescrossett
digitalifer
llexa
sleggat
stylz
alvaroisorna
ischenkodv
mmccrack
Arzakon
b0li
tomdebruin
crisb
remix4
enajenkins
nijitaro
vince2doom
fsorbello
heinz1959
pablodgavilan
jamesming
nickdoherty
esquareda
picale
jonhenshaw
superdeluxesam
titox
shaho
Leech
l1r
wilburhimself
higrade
grassdog
Wiederkehr
rubensarrio
jero
sulfurito
jimmysessions
SnipItPrpDemo
ahjo
chippper
asturi
rareyman
davu
matoilic
bambam
fugue
ginoplusio
moonbather
Sn0opy
loyst
salibaray
luggnagger
redstorm
VaiT
dviero
johnleestudio
peonhunter
baqc
fruehjahr
ilumin
aleprieto
gerhardsletten
wordGeek
LostCore
dong4138
francesL
justinscheetz
jder
Hilyin
shalva
rwczippy
tobiasmay
digiteyes
yuindustries
hdragomir
vevhlos
elbuenob
ntulip
jrharshath
Twain
bryandease
chrisjacob
kurrent
bsw1971
owais
bpdp
endorfin
Anber
ss44
cschlens
gpenston
powareverb
adesignapart
geothen
nreliu
d0ri0
hamiltonmascioli
delikassap
LordBumpet
bigheadlyf
johnloy
Triconium
ikimozu
nickBarker
g0mer
manteca
delarge
fsn
fragmentist
nightowl
darkapple
nb109
exanimo9
jpsirois
Hollow
lilumi
chodorowicz
caseybecking
kwitko
ericboehs
jedihawk
Tarale
smart1
ozenyx
redbaron_ict
superuntitled
vali29
markoburns
a1ias
obsessivejosh
jsw_nz
Meander365
sensimevanidus
svnlto
maznu
brainphat
jocko21
jackola
cnsaturn
zartgesotten
irishsk
jimredbaron
calvingilbert
acosonic
mailstefsteide
GrillPhil
visualpropaganda
pixelgraphix
isdereks
marvin_speakman
novatvstdios
turicon
jmiller
chirpyfalcon
retrobou
imsoper
Blacksnipe
sultano
aahmed753
ruhanirabin
ditzah
soccerspin
liupengf12
wkblackman
svenkaemper
debagel
Flocke
Nanobyte
olragon
Michael01
gushiken
bigredjoe
mikedish
quoctien82
xpoint
newpress
scitrenbaumgmailcom
eivind
skammer
galeksic
dancrew32
leighli
jrobinsonc
metoikos
sfhynx
richardf
jonahlyn
GandalfGrey
maryann
tariel
higash
ryanisinallofus
LyndseyPearce
smvnet
stcain


min-height for IE (and all other browsers)


Published in: CSS 






URL: http://www.cssplay.co.uk/boxes/minheight.html

Since min-height doesn't work in IE, this code makes up for IE's shortcomings. The first part of the code is the correct code that works in Firefox and Safari. The second part of the code is for IE. Internet Explorer will ignore min-height and is just given a height of 8em. The IE bug automatically expands the container to fit the extra text.

Expand | Embed | Plain Text
  1. /* for browsers that don't suck */
  2. .container {
  3. min-height:8em;
  4. height:auto !important;
  5. }
  6.  
  7. /* for Internet Explorer */
  8. /*\*/
  9. * html .container {
  10. height: 8em;
  11. }
  12. /**/

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: jonhenshaw on July 23, 2006

I wanted to make it clear that the the 8em is arbitrary and can be whatever height you would like it to be.

Posted By: Winkyboy on January 14, 2008

You don't really need the "* html" part of the IE definition, I think. This same solution can be found on DustinDiaz's site (http://www.dustindiaz.com/min-height-fast-hack/) without it. Example:

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

Posted By: rasmus on April 4, 2008

If you don't mind the undercore hack you can do it even shorter:

selector { min-height: 500px; _height: 500px; }

This way you avoid using !important for compliant browsers which may or may not trip you up later down the line (through css or style set through js).

Posted By: superdeluxesam on September 10, 2008

Is this specifically IE6 and lower? From my (admittedly brief) look through google it seems IE7 supports the property.

Posted By: Pring4 on November 10, 2008

This is specifically for IE6. It does not fully support IE5.5 and below. And yes, IE7 does support min-height properly.

Posted By: bambam on November 20, 2008

Only works for me (in IE7) if I put an !important on the 2nd section:

/* for browsers that don't suck */ .container { min-height:8em; height:auto !important; }

/* for Internet Explorer / /*/ * html .container { height: 8em !important; } /**/

Posted By: mihael on January 26, 2009

this could also be shortend like this:

container {

height:auto!important; mih-height:300px; height:300px: /for IE6/ }

Posted By: jaspertandy on April 13, 2009

yeah, those could go in the same declaration, as IE6 doesn't support !important or min-height so no hacks are required to get it to ignore those attributes. IE7 (to the best of my experience) supports !important and min-height so you're safe to use it there.

Posted By: joles04 on April 16, 2009

Joel Larios

Posted By: webdevelopertut on June 29, 2009

http://htmlcsstutorials.blogspot.com/2009/06/how-to-have-div-min-height.html

This tutorial will tell you how to give min-height, which will work in all the browsers including ie6

Posted By: webdevelopertut on June 29, 2009

http://htmlcsstutorials.blogspot.com/2009/06/how-to-have-div-min-height.html

This tutorial will tell you how to give min-height, which will work in all the browsers including ie6

Posted By: swiftouch on July 18, 2009

Here's an idea...use tables. they work everywhere. i honestly cant frickin believe people spend the time to figure out the latest css hack. i can't live that way. i want to get things done...until browsers stop supporting tables...tables it will be.

Posted By: LeeRJohnson on July 25, 2009

Here's an idea...stop using IE6. it worked everywhere in 2003. i honestly cant fuckin believe people spend the time to figure out how to make IE6 work. i can't live that way. i want to write proper code...until developers stop supporting IE6...IE6 it will be.

Posted By: ranjitsachin on August 7, 2009

hi rasmus,

You can specify _height. But its only for IE6 . But if u r specified *height, it will apply for all versions

Posted By: bucabay on September 3, 2009

A better solution is to use the expression() CSS function in IE.

Example:

/** css2 compliant */
#page_wrap {
    max-width: 800px;
    min-width: 600px;
}

/* ie min-width, max-width emulation */
* html #page_wrap {
    width: 800px; /* in case JS is off, set a fallback width. default is auto */
    width: expression(Math.max(Math.min((document.documentElement ? document.documentElement.clientWidth : document.body.clientWidth) - 20, 800), 600)+'px');
}

This example is a bit old, since IE7+ supports min/max dimensions, you should IE specific Comments.

The expiation is at: Min-Max witdh for IE

Posted By: smoothdzion on November 4, 2009

If you're going to use JavaScript, keep it out of the CSS.

Posted By: WebsiteDesign on January 13, 2010

IE creates problems for java scripts.It is better to use other browsers as Google Chrome,Mozilla to run these scripts without any hurdle.

You need to login to post a comment.