Easiest way to vertically centre an element in CSS

I’ve used many different ways to centre an element in CSS, this is the best way I’ve found so far (with bootstrap also).

.inmiddle { position: relative; top: 50%; -moz-transform: translateY(-50%); -ms-transform: translateY(-50%); -o-transform: translateY(-50%); -webkit-transform: translateY(-50%); transform: translateY(-50%); }

The above applied to the containing element centres itself and is responsive.

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.