Horizontal and Vertical Center [CSS snippet]


/* Horizontal Center */
#horizontalcenter {
    width: 400px; /* Change this to your container width */
    margin: 0 auto;
}
/* Vertical Center */
#verticalcenter {
    position: absolute;
    top: 50%;
    height: 400px; /* Change this to your container height */
    margin-top: -200px; /* This should be half your container height */
}

fin

Leave a Comment

Your comment may be edited or marked as spam if it appears intended for SEO purposes.