1

Here's the fiddle: http://jsfiddle.net/pehrlich/dNLLa/

The child div has a height of 50% of its parent. This confirms that the percentage-of-parent is working correctly. (As per Percentage Height HTML 5/CSS)

That same div has a margin top. If you change it to -50%; in the fiddle, you'll see that it moves completely out of view. The percentage for the margin is being read relative to something else-- perhaps the . It shouldn't be!

Community
  • 1
  • 1
Peter Ehrlich
  • 6,969
  • 4
  • 49
  • 65

1 Answers1

0

"The percentage is calculated with respect to the width of the generated box's containing block. Note that this is true for 'margin-top' and 'margin-bottom' as well. If the containing block's width depends on this element, then the resulting layout is undefined in CSS 2.1."

http://www.w3.org/TR/CSS21/box.html#margin-properties

Div margin-bottom of a proportion of its own height?

JS it is.

Community
  • 1
  • 1
Peter Ehrlich
  • 6,969
  • 4
  • 49
  • 65