xxxxxxxxxx
<article class="grid">
<div> 💌 </div
</article>
. grid {
display: grid;
place-items: center;
}
xxxxxxxxxx
.center {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
xxxxxxxxxx
.center{
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
xxxxxxxxxx
.element {
position: absoloute;
margin: auto;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
xxxxxxxxxx
/* Assume the div has a class of "center"
The below would center it horizontally
*/
.center {
margin-left: auto;
margin-right: auto;
}
/* There is a shorthand and it is given below */
.center {
margin: 0 auto;
}