【发布时间】:2019-10-09 02:08:02
【问题描述】:
我不是前端专家,我的应用程序中只需要几个图标,所以我认为与其依赖 font-awesome(带有巨大的 css 文件)这样的巨大图标包,我只需编写自己的图标css。这是我的想法(在 scss 中):
$icon-width: 24px;
$icon-height: 24px;
.thumbs-up {
width: $icon-width;
height: $icon-height;
&:before {
content: " ";
background: url(/icons/thumbs-up.svg) no-repeat;
width: 100%;
height: 100%;
display: block;
}
}
我可以像这样在我的 html 中简单地链接使用 thumbs-up:
> <p class="thumbs-up" id="like"></p>
这很好,我想知道这是否有任何缺陷,或者可能有更优雅的方法来做到这一点?
【问题讨论】:
-
如果您只需要几个图标,这种方法是最好的