Answers for "css align div in container"

CSS
31

how to center a div in css

.center {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
Posted by: Guest on March-31-2021
0

Align p, div, container in center in html

//align p
p {
  text-align: center;
}


//align container
/* Method 1: */
.container {
  display: flex;
  justify-content: center; // (or use)	margin: 0 auto;
  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 December-25-2021

Browse Popular Code Answers by Language