Last Updated: February 25, 2016
·
1.402K
· ajaswa

Vertically center arbitrarily sized content without the use of JS

Using CSS's inline-block, a pseudo-element and vertical-align you can vertically center any element of any or changing size with about 20 lines of CSS.

https://gist.github.com/3947564

3 Responses
Add your response

You don't even need 20 lines of CSS. See http://coderwall.com/p/oo2bqg (and first comment for the pseudo-element version).

over 1 year ago ·

@passcod Ahh good call. I guess I forgot to mention that mine also horizontally centers the element as well with out interfering with much else.

over 1 year ago ·

Well, the actual "payload" of vertically aligning css code is only under 10 lines :)

over 1 year ago ·