html - 如何实现像github.com这样的图标字体

标签 html css fonts icons sass

如何实现图标字体?

Github 在其网页上广泛使用它们,但试图重现其实现结果却以失败告终。

https://github.com/styleguide/css/7.0

在这里查看尝试的实现:

http://jsfiddle.net/spuder/jsmzm/7/

<div id="github">

    <span class="mega-icon mega-icon-blacktocat"></span>

</div>


.mega-icon-blacktocat {
    content:"\f209";
}



我已经阅读了很多关于图标字体的页面,并且通过了几个教程都没有成功

How to use icon fonts

http://css-tricks.com/examples/IconFont/

http://net.tutsplus.com/tutorials/html-css-techniques/quick-tip-ever-thought-about-using-font-face-for-icons/

Placing Unicode character in CSS content value

初学者。

更新 2013-4-11 提供的解决方案在 WebKit 中运行良好,在 firefox 20.0 中不起作用 http://jsfiddle.net/jsmzm/10/

最佳答案

here is your fiddle updated
基本上你在你的 span 标签中缺少 data-icon 属性

  <div id="github"> 
<span data-icon="" class="mega-icon mega-icon-blacktocat"></span>

和你的css中的引用

[data-icon]:before {
  font-family:'Octicons Regular';
  content: attr(data-icon);
  speak: none; 

关于html - 如何实现像github.com这样的图标字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16005795/

相关文章:

javascript - 单击一个圆圈并使其成为该部分/div 的大小

html - 在按钮上使用 display flex 使其在 Firefox 中换行

android - Android 浏览器/GUI(古吉拉特语)上的印度语呈现不当

javascript - vue js中的序列号无条件

javascript - 如何在 Internet Explorer 11 中获取 RadioNodeList 值?

javascript - 如何在 JavaScript 中定位下面的 div 的子元素

iPhone UIFont 粗体字体 带名称

javascript - 带有嵌套 ionic 导航 View 的 ionic 导航 View 不起作用

python - 如何链接到 django 上的用户个人资料

html - 行高与字体大小不匹配