3 ms·
Pretty cool, although I still don't understand how margin-top: 50%; moves the thing so far down ;) Damn you CSS!
by Meai 15y ago
Pretty cool, although I still don't understand how margin-top: 50%; moves the thing so far down ;)
Damn you CSS!
- bgrins 15y agohttp://www.w3.org/TR/CSS2/box.html#margin-properties 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/ http://jsfiddle.net/bgrins/999FP/