demo_unicode.html 5.59 KB
Newer Older
吴雪燕's avatar
init  
吴雪燕 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>IconFont</title>
    <link rel="stylesheet" href="demo.css">

    <style type="text/css">

        @font-face {font-family: "iconfont";
          src: url('iconfont.eot'); /* IE9*/
          src: url('iconfont.eot#iefix') format('embedded-opentype'), /* IE6-IE8 */
          url('iconfont.woff') format('woff'), /* chrome, firefox */
          url('iconfont.ttf') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
          url('iconfont.svg#iconfont') format('svg'); /* iOS 4.1- */
        }

        .iconfont {
          font-family:"iconfont" !important;
          font-size:16px;
          font-style:normal;
          -webkit-font-smoothing: antialiased;
          -webkit-text-stroke-width: 0.2px;
          -moz-osx-font-smoothing: grayscale;
        }

    </style>
</head>
<body>
    <div class="main markdown">
        <h1>IconFont 图标</h1>
        <ul class="icon_lists clear">
            
                <li>
                <i class="icon iconfont">&#xea3f;</i>
                    <div class="name">show-password </div>
                    <div class="code">&amp;#xea3f;</div>
                </li>
            
                <li>
                <i class="icon iconfont">&#xe89a;</i>
                    <div class="name">user</div>
                    <div class="code">&amp;#xe89a;</div>
                </li>
            
                <li>
                <i class="icon iconfont">&#xe8b5;</i>
                    <div class="name">users</div>
                    <div class="code">&amp;#xe8b5;</div>
                </li>
            
                <li>
                <i class="icon iconfont">&#xe66c;</i>
                    <div class="name">password-b</div>
                    <div class="code">&amp;#xe66c;</div>
                </li>
            
                <li>
                <i class="icon iconfont">&#xe888;</i>
                    <div class="name">06商品</div>
                    <div class="code">&amp;#xe888;</div>
                </li>
            
                <li>
                <i class="icon iconfont">&#xe89b;</i>
                    <div class="name">25单据</div>
                    <div class="code">&amp;#xe89b;</div>
                </li>
            
                <li>
                <i class="icon iconfont">&#xe89f;</i>
                    <div class="name">28体积、空间</div>
                    <div class="code">&amp;#xe89f;</div>
                </li>
            
                <li>
                <i class="icon iconfont">&#xe8c9;</i>
                    <div class="name">225默认头像</div>
                    <div class="code">&amp;#xe8c9;</div>
                </li>
            
                <li>
                <i class="icon iconfont">&#xe902;</i>
                    <div class="name">406报表</div>
                    <div class="code">&amp;#xe902;</div>
                </li>
            
                <li>
                <i class="icon iconfont">&#xe709;</i>
                    <div class="name">lock_fill</div>
                    <div class="code">&amp;#xe709;</div>
                </li>
            
        </ul>
        <h2 id="unicode-">unicode引用</h2>
        <hr>

        <p>unicode是字体在网页端最原始的应用方式,特点是:</p>
        <ul>
        <li>兼容性最好,支持ie6+,及所有现代浏览器。</li>
        <li>支持按字体的方式去动态调整图标大小,颜色等等。</li>
        <li>但是因为是字体,所以不支持多色。只能使用平台里单色的图标,就算项目里有多色图标也会自动去色。</li>
        </ul>
        <blockquote>
        <p>注意:新版iconfont支持多色图标,这些多色图标在unicode模式下将不能使用,如果有需求建议使用symbol的引用方式</p>
        </blockquote>
        <p>unicode使用步骤如下:</p>
        <h3 id="-font-face">第一步:拷贝项目下面生成的font-face</h3>
        <pre><code class="lang-js hljs javascript">@font-face {
  font-family: <span class="hljs-string">'iconfont'</span>;
  src: url(<span class="hljs-string">'iconfont.eot'</span>);
  src: url(<span class="hljs-string">'iconfont.eot?#iefix'</span>) format(<span class="hljs-string">'embedded-opentype'</span>),
  url(<span class="hljs-string">'iconfont.woff'</span>) format(<span class="hljs-string">'woff'</span>),
  url(<span class="hljs-string">'iconfont.ttf'</span>) format(<span class="hljs-string">'truetype'</span>),
  url(<span class="hljs-string">'iconfont.svg#iconfont'</span>) format(<span class="hljs-string">'svg'</span>);
}
</code></pre>
        <h3 id="-iconfont-">第二步:定义使用iconfont的样式</h3>
        <pre><code class="lang-js hljs javascript">.iconfont{
  font-family:<span class="hljs-string">"iconfont"</span> !important;
  font-size:<span class="hljs-number">16</span>px;font-style:normal;
  -webkit-font-smoothing: antialiased;
  -webkit-text-stroke-width: <span class="hljs-number">0.2</span>px;
  -moz-osx-font-smoothing: grayscale;
}
</code></pre>
        <h3 id="-">第三步:挑选相应图标并获取字体编码,应用于页面</h3>
        <pre><code class="lang-js hljs javascript">&lt;i <span class="hljs-class"><span class="hljs-keyword">class</span></span>=<span class="hljs-string">"iconfont"</span>&gt;&amp;#x33;<span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">i</span>&gt;</span></span></code></pre>

        <blockquote>
        <p>"iconfont"是你项目下的font-family。可以通过编辑项目查看,默认是"iconfont"。</p>
        </blockquote>
    </div>


</body>
</html>