1

Possible Duplicate:
height:100%; not working

I have two divs, one inside another. Both are set to 100% in height. Container (A) is sized properly and fills its parent but its child (B) is not being stretched to its height. When I set container (A) height in pixels, e.g. 500px, its child (B) stretches properly.

But I need container (A) to be set in percents, not pixels. What am I doing wrong?

Community
  • 1
  • 1
Sergei Basharov
  • 51,276
  • 73
  • 200
  • 335

1 Answers1

1

height:100%, or any percentage value, only works if the parent has an height set too.

So, in your case, the parent of div A can be either another element or the body. If that's the case, add this rule:

html, body { height:100%; }

to your CSS. Then it will work.

Giona
  • 20,734
  • 4
  • 56
  • 68