Answers for "how to center child elements in div"

CSS
90

center a div in css

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

center div horizontally and vertically

.parent {
  position: relative;
}
.child {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}
Posted by: Guest on June-22-2020
4

how to center a div element

/*ADD MARGIN auto to left and right*/
.box1{
    width:80%;
    margin:0 auto;
}
Posted by: Guest on August-27-2020
0

how to center anything inside your container

display: grid;
    place-items: center;
    height: 100vh;
Posted by: Guest on September-06-2020
0

center child container

Container(
        width: double.infinity,
        height: 500,
        color: Colors.amber,
        alignment: Alignment.center,
        child: Container(
          width: 200,
          height: 200,
          color: Colors.red,
        ),
),
Posted by: Guest on September-29-2021

Code answers related to "how to center child elements in div"

Browse Popular Code Answers by Language