使用icon font来生成图标相对于基于图片的图标来说,有如下的好处:
文字修饰:
<h3> <span aria-hidden="true" data-icon="⇝"></span> Stats </h3> [data-icon]:before { font-family: icons; /* BYO icon font, mapped smartly */ content: attr(data-icon); speak: none; /* Not to be trusted, but hey. */ }
单独图标:
<a href="#" class="icon-alone"> <span aria-hidden="true" data-icon="▨"></span> <span class="screen-reader-text">RSS</span> </a> /* Same CSS as above, plus */ .icon-alone { display: inline-block; /* Chrome 19 was weird with clickability without this */ } .screen-reader-text { /* Reusable, toolbox kind of class */ position: absolute; top: -9999px; left: -9999px; }
如果大家需要创建自己的iconfont,推荐使用iconmoon,使用它你可以通过上传SVG或者字体来生成你需要的icon字体,本文在线演示使用iconmoon生成。
步骤1:选择他们提供的或者上传自己的
......