Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Vertically Align a Table in CSS

How can I vertically align a table in the middle of the screen with css?

like image 569
Deano Avatar asked Nov 05 '22 22:11

Deano


1 Answers

Generally something along the lines of this works pretty well in any block element with a defined height.

table { 
 position: absolute;
 top: 50%;
 margin-top: -50%;
}

Centering on the page is harder since you don't have a defined height, but I think this works.

html {
 height: 100%;
}

You may encounter some browser differences, act accordingly.

like image 55
Mike Robinson Avatar answered Nov 15 '22 09:11

Mike Robinson