Re:Labcss.net - An HTML/CSS snippet, allows direct visual ma...
by Meai on Wednesday September 14, 2011 @05:05AM
(#2995444)
Pretty cool, although I still don't understand how margin-top: 50%; moves the thing so far down ;)
Damn you CSS!
[ Parent
| on HN ]
Re:Labcss.net - An HTML/CSS snippet, allows direct visual ma...
by bgrins on Wednesday September 14, 2011 @08:40AM
(#2995987)
http://www.w3.org/TR/CSS2/box.html#margin-properties
When margin top or bottom is a percentage, it refers to the width, not height, of the containing block. If the parent is 100% width (say, the body), the element will move down 50% of your screen width.
Usually, you don't want this, but you can use it to do some cool tricks with keeping the aspect ratio of an element, like this: http://jsfiddle.net/bgrins/999FP/