display: flex;
align-items: center;
justify-content: center;
/* order: vertical, horizontal */
/* If you need to access this quickly, just search for "fc" */
.container {
font-family: arial;
font-size: 24px;
margin: 25px;
width: 350px;
height: 200px;
outline: dashed 1px black;
/* Center child horizontally*/
display: flex;
justify-content: center;
}
.child {
width: 50px;
height: 50px;
background-color: red;
}
// example 1
div { display: grid; place-items: center; }
// example 3
div{ display:flex; align-items:center; }
// example 3
div { width: 100%; margin: 0 auto; }
.center {
text-align: center;
border: 3px solid green;
}
/* the simple solution*/
table {
text-align: center;
}
.center {
margin: auto;
width: 50%;
border: 3px solid green;
padding: 10px;
}
.container {
font-family: arial;
font-size: 24px;
margin: 25px;
width: 350px;
height: 200px;
outline: dashed 1px black;
/* Center child horizontally*/
display: flex;
justify-content: center;
}
.child {
width: 50px;
height: 50px;
background-color: red;
}