zoukankan      html  css  js  c++  java
  • 使用@font-face来实现icon

    @font-face制作Web Icon     

     

    @font-face规则在css2中已经存在,但在css2.1中被删除,在css3中又重新被引入。自从Metro 风格被大多前段程序员青睐后,使用@font-face制作web icon 已经广泛使用于网页设计
    下面例子是制作Metro风格按钮
     
    1.在网站http://icomoon.io/app/上下载所需的图标
     
    压缩包中包含有相应的例子
     
    2.把fonts文件夹添加都你的网页文件中,
    在css文件中初始化字体样式
    @font-face {
    font-family: 'icomoon';
    src:url('fonts/icomoon.eot');
    src:url('fonts/icomoon.eot?#iefix') format('embedded-opentype'),
    url('fonts/icomoon.woff') format('woff'),
    url('fonts/icomoon.ttf') format('truetype'),
    url('fonts/icomoon.svg#icomoon') format('svg');
    font-weight: normal;
    font-style: normal;
    }
     
    3.引用字体样式
    [data-icon]:before {
    font-family: 'icomoon';
    content: attr(data-icon);
    speak: none;
    font-weight: normal;
    font-variant: normal;
    text-transform: none;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    }
    4.下面是html代码
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>使用@font-face来实现icon</title>
    </head>
     
    <body>
    <a class="btn" data-icon="&#xe002;" aria-hidden="true" href="http://www.baidu.com/"></a>
    </body>
    </html>
    4.为btn添加css样式
    .btn{ display:block; height:100px;line-height:100px; 100px; background:#09F; text-align:center; font-size:3em; cursor:pointer; 
    }
    5.效果图
  • 相关阅读:
    hive函数总结
    python判断文件和目录是否存在
    python中的参数
    写hive db的两种方法
    python中argparse模块的使用
    python数据持久存储:pickle模块的使用
    python读文件
    mysql 将时间戳直接转换成日期时间
    shell日期的应用
    [转]SQL UNION 和 UNION ALL 操作符
  • 原文地址:https://www.cnblogs.com/Kenvon/p/3280654.html
Copyright © 2011-2022 走看看