为什么用svg放弃了iconfont?
为什么 放弃 SVG Iconfont
2023-09-11 14:14:36 时间
svg替代iconfont的好处(无论是基于Vue、Jquery),都推荐svg
http://www.woshipm.com/pd/463866.html
svg图标库,svg图标在线制作
https://icomoon.io/app/#/select
svg体积优化
https://jakearchibald.github.io/svgomg/?utm_source=next.36kr.com
示例代码(建议uniapp运行环境,修改也可以vue环境运行,需支持sass处理)
1 <template>
2 <view>
3 <view class="svg-list">
4 <view class="icon-facebook"></view>
5 <view class="icon-twitter"></view>
6 <view class="icon-feed"></view>
7 <view class="icon-youtube"></view>
8 </view>
9 </view>
10 </template>
11
12 <script>
13 export default {
14 data() {
15 return {
16
17 };
18 }
19 }
20 </script>
21
22 <style lang="scss">
23 $icons: google-plus,
24 facebook,
25 twitter,
26 feed,
27 youtube,
28 vimeo,
29 lanyrd,
30 forrst,
31 deviantart,
32 steam,
33 github,
34 wordpress,
35 blogger,
36 tumblr,
37 soundcloud,
38 linkedin,
39 lastfm,
40 delicious,
41 stumbleupon,
42 pinterest,
43 xing,
44 flattr;
45
46
47 .svg-list {
48 display: flex;
49 [class*="icon-"] {
50 margin: 2%;
51 }
52 }
53
54 [class^="icon-"] {
55 display: block;
56 width: 64upx;
57 height: 64upx;
58 text-indent: 100%;
59 overflow: hidden;
60 white-space: nowrap;
61 background: url(http://www.w3cplus.com/sites/default/files/blogs/2015/1506/sprite.svg) no-repeat;
62
63 @for $i from 1 through length($icons) {
64 &.icon-#{nth($icons,$i)} {
65 background-position: 0 -1 * (($i - 1) * 84upx);
66 }
67 }
68 }
69 </style>
来自大漠的一篇博文:https://www.w3cplus.com/svg/create-svg-sprite-sheet.html
相关文章
- 为什么C++永不过时?
- 什么是线程?什么是进程?为什么要有线程?有什么关系与区别?
- 1.为什么要学习MATLAB
- 为什么多数科技热点对于创业企业来说是误导
- CSDN日报20170717——《程序员,为什么写不好一份简历?》
- 9张图,Kafka为什么要放弃Zookeeper
- i++为什么不是原子操作?
- 为什么 StackOverflow 上的代码片段会摧毁你的项目?
- 为什么要讲数据结构和算法?以及如何学习数据结构和算法
- 为什么 Category 不能增加成员变量-nonfragile
- 浅析分布式一致性算法 - Raft算法:定义、为什么需要一致性、强/弱一致性分类区别、raft三种状态、领导选举算法流程、日志复制流程、安全选举限制、如何解决split brain的问题
- 为什么越来越少的人用jQuery
- 微软为什么总在周二发布系统更新,而不是立刻修复安全漏洞?
- 华为为什么赢?为什么是华为赢?