How to align a div vertically and horizontally
This is the solution for align a div vertically and horizontally with css.
<html> <head> <title>creativetweets.com</title> <style> .center { height: 200px; position: relative; border: 3px solid red; /*creativetweets.com*/ } .center p { margin: 0; position: absolute; top: 50%; left: 50%;/*creativetweets.com*/ -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%); } </style> </head> <body> <h2>How to align a div vertically and horizontally - creativetweets.com </h2> <div class="center"> <p>this text is vertically and horizontally centered. creativetweets.com</p> </div> </body> </html>