Center Div di tengah halaman
.centered {
position: fixed;
top: 50%;
left: 50%;
/* bring your own prefixes */
transform: translate(-50%, -50%);
}
Glamorous Gentoo
.centered {
position: fixed;
top: 50%;
left: 50%;
/* bring your own prefixes */
transform: translate(-50%, -50%);
}
IMG.displayed {
display: block;
margin-left: auto;
margin-right: auto }
...
<IMG class="displayed" src="..." alt="...">
.parent {
position: relative;
}
.child {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
display: flex;
align-items: center;
justify-content: center;
/* order: vertical, horizontal */
/* If you need to access this quickly, just search for "fc" */
// example 1
div { display: grid; place-items: center; }
// example 3
div{ display:flex; align-items:center; }
// example 3
div { width: 100%; margin: 0 auto; }
/* the simple solution*/
table {
text-align: center;
}