使用svg製作字型圖示

lkycan發表於2017-12-14

###1.訪問連結轉換svg字型的網站 https://icomoon.io/

Paste_Image.png

###2.匯入SVG圖示

Paste_Image.png


Paste_Image.png

###3.選中你要轉換的SVG圖示

Paste_Image.png


Paste_Image.png


###4.設定資訊 設定icon名稱以及相關資訊

Paste_Image.png


Paste_Image.png

生成例子以及相關樣式程式碼:

Paste_Image.png
####5.主要是生成的css檔案 style.css

@font-face {
  font-family: 'icomoon';
  src:  url('fonts/icomoon.eot?xhzg4r');
  src:  url('fonts/icomoon.eot?xhzg4r#iefix') format('embedded-opentype'),
    url('fonts/icomoon.ttf?xhzg4r') format('truetype'),
    url('fonts/icomoon.woff?xhzg4r') format('woff'),
    url('fonts/icomoon.svg?xhzg4r#icomoon') format('svg');
  font-weight: normal;
  font-style: normal;
}

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

.icon-appicon:before {
  content: "\e902";
}

複製程式碼

把生成的fonts裡面的所有檔案拷貝到你需要的開發環境

Paste_Image.png


###6.實際呼叫 只需要給相關的類名即可以,類名就是之前生成的時候你編寫的名字前面加上icon-,如果沒有改,就是你svg檔案的名字。

<span class="icon-appicon"></span>
複製程式碼

Paste_Image.png

相關文章