变换比例稍微微调 Font Awesome 图标
Transform scale slightly nudges Font Awesome icon
我在父级 div 中有一个 Font Awesome 图标,其中 display: flex
本身位于容器 div 中,即 display: flex
.
当我尝试 transform: scale(1.2)
悬停时,它会稍微推动元素:
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>
知道为什么会这样吗?
改用 SVG 版本,您就不会遇到这个问题。缩放 SVG 优于缩放文本:
.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>
相关:
我在父级 div 中有一个 Font Awesome 图标,其中 display: flex
本身位于容器 div 中,即 display: flex
.
当我尝试 transform: scale(1.2)
悬停时,它会稍微推动元素:
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>
知道为什么会这样吗?
改用 SVG 版本,您就不会遇到这个问题。缩放 SVG 优于缩放文本:
.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>
相关: