Share the post "Center Div Horizontally And Vertically Using CSS"
By far this is the best solution that I have come across with with regards to placing a Div element at the center both horizontally and vertically.
|
1 2 3 |
<div style="position: relative; left: 50%; top: 50%; transform: translate(-50%,-50%);"> ... </div> |
Add your custom width and height values to complete the result.
If you do not assign a width and height value, the Div will stretch its width to fill the screen but its height will be centered vertically depending on the content.