图标字体

有时页面上要用到一些小图标,按以前的方法在网上搜图片下载再应用到页面上的效率会比较低,效果也不怎么好。可以考虑用css3的font-face属性,它可以把我们自定义的Web字体或图标字体嵌入到你的网页中,我们可以通过设置font-size来设置图标的大小。非常的简单和方便。

https://icomoon.io/app/#/select    和    http://fontello.com/这两个网站都是免费Web-font 图标大集合。

在网上下载自己的图标字体集,导入引用再修改一下就可以用啦

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        @font-face {
            font-family: 'ff';
            src:url('fonts/ff.eot?l6gayx');
            src:url('fonts/ff.eot?#iefixl6gayx') format('embedded-opentype'),
            url('fonts/ff.woff?l6gayx') format('woff'),
            url('fonts/ff.ttf?l6gayx') format('truetype'),
            url('fonts/ff.svg?l6gayx#ff') format('svg');
            font-weight: normal;
            font-style: normal;
        }
        .icon{
            font-family: 'ff';
            font-size: 30px;
        }
        .box{
            margin: 20px auto;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="box">
        <span class="icon">b</span>
        <span class="icon">e</span>
        <span class="icon">f</span>
    </div>
</body>
</html>
View Code

 

posted @ 2014-10-21 17:42  jellyANDjammy  阅读(181)  评论(0编辑  收藏  举报