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;
}
xxxxxxxxxx
.div-centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
xxxxxxxxxx
div.center {
text-align: center;
align-items: center;
align-self: center;
justify-content: center;
justify-self: center;
justify-items: center;
justify-tracks: center;
text-justify: center;
place-items: center;
place-self: center;
padding-left: center;
vertical-align: middle;
line-height: 100%;
margin: auto;
position: absolute;
left: 50%;
right: 50%;
transform: translate(-50%, -50%);
}