In this tutorial will learn how to center div,span or any element vertically using css3 in just few lines of code.
For align center we are using transform translate css property. see below image, you can see Main grey div in which one green div is align vertically centered.
So, lets start with css,
-moz-transform: translateY(-50%); /* For mozilla support */
-webkit-transform: translateY(-50%); /* For safari support */
-ms-transform: translateY(-50%); /* For IE support */
-o-transform: translateY(-50%); /* For opera support */
By applying position relative , top and transform we can easily align vertically centered.
See full code with HTML & CSS
Hope this tutorial is helpful for you.
I build websites | Been building websites for the last 3 years and been venturing into App Development now.