-2

If you needed to horizontally and vertically center an object within a container that has no set height, how would you accomplish that?

Farhad
  • 4,119
  • 8
  • 43
  • 66
Riju Ss
  • 1
  • 1

1 Answers1

0

.centerDiv {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
<div class="centerDiv">hello</div>
Pawan Kumar
  • 1,374
  • 7
  • 14