A universal and easy way for creating divs whose content is vertically or both horizontally and vertically centered.
Referece: Centering in CSS: A Complete Guide
If you like this solution, would you please follow me and/or star this project on Github? Thanks!
- Include the css file by adding
<link href=".../css3-centered-divs.css" rel="stylesheet>
inside your html element. - Insert a
<div class="centered-div">...</div>
or<div class="vertically-centered-div>...</div>
to wrap the content that you want to center.