沿用同行思密達的方法整理了一下;前提是先引入iconfont字體圖標(引用線上iconfont查看上篇隨筆):好比
其中&#
是開頭用以標明這是字符實體,x
表示這是十六進制,而CSS的content接受的也是16進制的Unicode編碼,因此能夠直接寫 content: "\e7bb";
css
別忘記把font-family:"iconfont"寫進去,很重要的字體
<style typel="text/css"> .show:before{ font-family: "iconfont"; content: "\eae2"; color: red; width: 20px; height: 20px; position: absolute; left: 5%; } </style> <div class="show"></div>