Center any element with css (vertically and horizontally)

If you only care about modern browsers this is a great way to center elements on a page using only a few lines of css.

.container {
position: relative;
}

.center {
position: absolute;
top:50%;
left:50%;
transform: translate(-50%,-50%);
}

Leave a Reply

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

Unable to load the Are You a Human PlayThru™. Please contact the site owner to report the problem.