5txhog
Last Updated: February 25, 2016
·
1.229K
· ajaswa
0faa165c38949ba158e9104cc22ed8cb

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

Say Thanks
Respond

3 Responses
Add your response

2050
11904d2d1af36d532f9d78d9d59f6819

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 ·
2052
0faa165c38949ba158e9104cc22ed8cb

@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 ·
4500
D42a7264714dee5006b9c99d2567a320

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

over 1 year ago ·