Center the content in div vertically and horizontally

To make the content in a div vertically and horizontally center

    text-align:center; 

property will set the content  horizontally center of a div.

vertical-align:middle; property will set the content  vertically center of a div. but to make the content positioned exactly to fit in the center   line-height:400px; set the line height to the half of the height and width.

HTML:

Learning Chameleon

css:

.container{
    width:400px;
    height:400px;
    background-color:green;
   text-align:center;
   vertical-align:middle;
   line-height:400px;
}

CodePen Ref: Code pen source code


Here are the some of the book recommendations :

           
Enable GingerCannot connect to Ginger Check your internet connection
or reload the browser
Disable in this text fieldEditEdit in GingerEdit in GingerΓ—

Enable GingerCannot connect to Ginger Check your internet connection
or reload the browser
Disable in this text fieldEditEdit in GingerEdit in GingerΓ—

Leave a Reply

Your email address will not be published. Required fields are marked *

Enable Notifications OK No thanks