How to host material icons offline?

后端 未结 19 2483
无人及你
无人及你 2020-12-02 06:55

My apologies if this is a very simple question, but how do you use google material icons without a



        
19条回答
  •  死守一世寂寞
    2020-12-02 07:37

    I have tried to compile everything that needs to be done for self-hosting icons in my answer. You need to follow these 4 simple steps.

    1. Open the iconfont folder of the materialize repository

      link- https://github.com/google/material-design-icons/tree/master/iconfont

    2. Download these three icons files ->

      MaterialIcons-Regular.woff2 - format('woff2')

      MaterialIcons-Regular.woff - format('woff')

      MaterialIcons-Regular.ttf - format('truetype');

      Note- After Download you can rename it to whatever you like.

    3. Now, go to your CSS and add this code

    @font-face {
      font-family: 'Material Icons';
      font-style: normal;
      font-weight: 400;
      src: url(MaterialIcons-Regular.eot); /* For IE6-8 */
      src: local('Material Icons'),
           local('MaterialIcons-Regular'),
           url(MaterialIcons-Regular.woff2) format('woff2'),
           url(MaterialIcons-Regular.woff) format('woff'),
           url(MaterialIcons-Regular.ttf) format('truetype');
    }
    
    .material-icons {
      font-family: 'Material Icons';
      font-weight: normal;
      font-style: normal;
      font-size: 24px;  /* Preferred icon size */
      display: inline-block;
      line-height: 1;
      text-transform: none;
      letter-spacing: normal;
      word-wrap: normal;
      white-space: nowrap;
      direction: ltr;
    
      /* Support for all WebKit browsers. */
      -webkit-font-smoothing: antialiased;
      /* Support for Safari and Chrome. */
      text-rendering: optimizeLegibility;
    
      /* Support for Firefox. */
      -moz-osx-font-smoothing: grayscale;
    
      /* Support for IE. */
      font-feature-settings: 'liga';
    }


    Note : The address provided in src:url(...) should be with respect to the 'CSS File' and not the index.html file. For example it can be src : url(../myicons/MaterialIcons-Regular.woff2)


    1. You are ready to use now and here is how it can be done in HTML

    face

    Click here to see all the icons that can be used.

提交回复
热议问题