css - 规模 :before when hovering

标签 css animation hover scale

我正在尝试缩放 :before我的内容<span> 到目前为止,悬停时会应用样式,但没有视觉变化,:before保持相同的比例。

到目前为止我得到了什么:

<div class="comment-actions">
  <span class="comment-likes icon-ico-heart">
    12
  </span>
</div>

SASS(CSS):

.comment-likes
  transition: all 100ms ease-in-out
  color: #92a3b9
  cursor: pointer

  &:hover::before
    transform: scale(1.5)

Icomoon:

.icon-ico-heart:before {
  content: "\e914";
}

[class^="icon-"], [class*=" icon-"] {
  /* use !important to prevent issues with browser extensions that change fonts */
  font-family: 'icomoon' !important;
  speak: none;
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  text-transform: none;
  line-height: 1;

  /* Better Font Rendering =========== */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

最佳答案

增加悬停时的 font-size 并为其添加 transition 属性。

.icon-ico-heart:before {
    font-size: 10px;
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    -ms-transition: all 0.3s ease;
    transition: all 0.3s ease;
}

.icon-ico-heart:hover:before {
    font-size: 15px;
}

您可以只使用 transition: font 0.3s ease; 只为字体应用过渡而不是所有

关于css - 规模 :before when hovering,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40237329/

相关文章:

CSS :after pseudo checkbox not working in IE or Firebug

swift - 以随机延迟(一个接一个)和随机水平位置动画滚动图像

c# - 显示动画直到操作完成 wpf

jquery - 在 Javascript 的 for 循环中分配点击处理程序

css - 当鼠标在 div 内时,如何使 div 内的所有链接改变颜色?

firefox - @font-face 在 Firefox 中不工作?

CSS - 并排放置两个条

jquery - 向 Bootstrap 导航栏添加额外的动画

jQuery every : loop an array, 通过 jQuery 附加文本并执行动画

javascript - 如何让 SetInterval 在悬停关闭时停止?