Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSS

how to center a div in css

/* Assume the div has a class of "center"
   The below would center it horizontally
*/
.center {
	margin-left: auto;
    margin-right: auto; 
}

/* There is a shorthand and it is given below */
.center {
	margin: 0 auto; 
}
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #center #div #css
ADD COMMENT
Topic
Name
7+2 =