Scale :before when hovering

半城伤御伤魂 提交于 2019-12-25 04:07:33

问题


I'm trying to scale the :before content of my <span> when hovering over it. So far the style gets applied when hovering but there are no visual changes, the :before remains the same scale.

What I've got so far:

<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;
}

回答1:


Don't transform it with the scale property but use the font-size. So:

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



回答2:


Increase the font-size on hover and add transition property to it.

.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;
}

You can use just transition: font 0.3s ease; to apply transition only for font instead of all




回答3:


You may not able to use the scale property for fonts or icon fonts,

Instead of this you can use font size property.



来源:https://stackoverflow.com/questions/40237329/scale-before-when-hovering

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!