Centre un div CSS
.center {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
Puzzled Penguin
.center {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.center {
display: block;
margin-left: auto;
margin-right: auto;
}
.parent {
position: relative;
}
.child {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.parent {
display: flex;
justify-content: center;
align-items: center;
}
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%);
}