css图标 | 来自 fontawesome 字体文件的586 个小图标

1. css效果

/*!
 *  Font Awesome 4.4.0 by @davegandy - http://fontawesome.io - @fontawesome
 *  License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License)
 */
 
.fa-glass:before {content:"\f000"}
.fa-music:before {content:"\f001"}
.fa-search:before {content:"\f002"}
.fa-envelope-o:before {content:"\f003"}
.fa-heart:before {content:"\f004"}

2. 使用py批量转换为html格式

# part I 转化一个
def toCss(str2):
    #str2='.fa-glass:before {content:"\f000"}'
    import re 
    arr = re.split(':', str2)[0]
    arr=arr[1:]
    return "<i class='fa %s' title='%s'></i>" %(arr, arr)

# test
toCss('.fa-film:before {content:"\f008"}')
## "<i class='fa fa-film' title='fa-film'></i>"


# part II 转换全部
fr = open("css.txt", 'r')
fw = open("index.html", 'w')
header="""
<meta charset="utf-8">
<link rel="stylesheet" href="/static/css/font-awesome.min.css">

<style>
i{margin:10px;}
</style>
"""
fw.write(header + "\n")

i=0
while True:
    i +=1
    if i>10:
        #break
        pass
    lineR = fr.readline()
    if not lineR:
        break;
    line = lineR.strip()
    
    css = toCss(line)
    #print(i, line, css)
    fw.write(css + "\n")
fr.close()
fw.close()

print("end", i)
# 586 个小图标

3.效果图

在这里插入图片描述
可以目测效果图,然后鼠标右击查看样式代码。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值