Answers for "css align divs center"

CSS
89

center a div in css

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

center div css

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

different ways to center a div

/* Centering an element without flexbox */
.parent-element {
  position: relative;
}

.child-element {
	position: absolute;
  	left: 50%;
  	top: 50%;
  	transform: translate(-50%, -50%);
}

/* Centering an element using flexbox */
.parent-element {
	display: flex;
  	align-items: center;
  	justify-content: center;
}
Posted by: Guest on June-30-2021
1

div center

#inner {
  display: table;
  margin: 0 auto;
  border: 1px solid black;
}

#outer {
  border: 1px solid red;
  width:100%
}
Posted by: Guest on December-07-2020
3

how to center a div

margin:auto
Posted by: Guest on August-13-2020

Browse Popular Code Answers by Language