-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
  • 6,158
  • 8
  • 38
  • 63
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,334
  • 6
  • 13