Aligning Elements with CSS Transforms

CSSHere’s some quick CSS for horizontally or vertically centering any element. It’s all done with CSS3 transforms, meaning it’s a solution that will work anywhere from at or newer than IE 9, Chrome 31, Safari 7.1 and Android Browser 4.1. The only caveat is that you’ll need MS and webkit prefixes for those older versions of the browsers.

There’s also no Opera Mini support, which shouldn’t affect many users, but use your own site’s analytics to confirm that you don’t have a bunch of users coming from Opera Mini, or other unsupported browser (IE8).

Vertically and Horizontally Align Any Element with CSS3 Transforms

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.