center div css

41

.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="...">

Comments

Submit
0 Comments