Answers for "how to align a div to center in css"

CSS
89

center a div in css

.container {
  display: flex;
  justify-content: center;
  align-items: center;
}
Posted by: Guest on September-09-2020
0

how to center a div

/* Method 1: */
.container {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Method 2: */
.container {
	display: grid;
	place-items: center
}

/* Method 3: */
.center-div {
	margin: auto;
}

/* Method 4: */
.center-div {
  position: absolute;
  left: 50%;
  top: 50%;
}
Posted by: Guest on October-06-2021

Code answers related to "how to align a div to center in css"

Browse Popular Code Answers by Language