0

I am using scale to enlarge an element on hover, and it was working fine until I added transform:translate(-50%,-50%); . Then it started to scale the element from the bottom right, not from the center. Here is my code:

.skyimage{
  height:100px;
  width:100px;
  position:absolute;
  left:50%;
  transform:translate(-50%,-50%);
  top:150px;
  transition:.5s;
  background:transparent;
}


.skyimage:hover{
  transform:scale(1.2) translate(-50%,-50%);
}
Temani Afif
  • 245,468
  • 26
  • 309
  • 415
HoneyPoop
  • 473
  • 1
  • 6
  • 25

1 Answers1

-1

Meaning of transform: translate(-50%,-50%) is :-

-move me leftwards by 50% of my width, along the x-axis, and

-move me upwards by 50% of my height, along the y-axis

hence this will not zoom the image from the center, for that scale is enough

VR7
  • 112
  • 3
  • 16