Auto set an element at center of its parent element when its position is absolute

Add the basic class of css below into your css file:

.parent {
  width: 100%;
  height: 400px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.elements {
  position: absolute;
  background: #999;
}


Usage:

 
Your element


csshtml

© 2019 4codev

Created with love by Sil.