1

I have a Font Awesome icon inside a parent div with display: flex which itself is inside a container div that's display: flex.

When I try transform: scale(1.2) on hover it slightly nudges the element:

https://jsfiddle.net/Daniel_Knights/gptyo3be/5/

.container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}

.parent {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100px;
  height: 100px;
}

i {
  cursor: pointer;
  transition: transform 0.2s;
}

i:hover {
  transform: scale(1.2);
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.13.0/css/all.css">

<div class="container">
  <div class="parent">
    <i class="fa fa-eye" id="single-item-eye"></i>
  </div>
</div>

Any ideas why this might be?

Temani Afif
  • 245,468
  • 26
  • 309
  • 415
Daniel_Knights
  • 7,940
  • 4
  • 21
  • 49

1 Answers1

1

Use the SVG version instead and you won't have the issue. Scaling an SVG is better than scaling a text:

.container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}

.parent {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100px;
  height: 100px;
}

svg {
  cursor: pointer;
  transition: transform 0.2s;
}

svg:hover {
  transform: scale(1.2);
}
<script  src="https://use.fontawesome.com/releases/v5.13.0/js/all.js"></script>

<div class="container">
  <div class="parent">
    <i class="fa fa-eye" id="single-item-eye"></i>
  </div>
</div>

Related: Why is text getting blurry and wobbles during 2d scale transform

Temani Afif
  • 245,468
  • 26
  • 309
  • 415