让前端飞Web前端之路h5前端开发

阿里iconfont字体图标的使用

2019-10-11  本文已影响0人  手指乐
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    @font-face {
        font-family: 'iconfont';
        /* project id 1303894 */
        src: url('http://at.alicdn.com/t/font_1303894_e6bbqut2108.eot');
        src: url('http://at.alicdn.com/t/font_1303894_e6bbqut2108.eot?#iefix') format('embedded-opentype'), url('http://at.alicdn.com/t/font_1303894_e6bbqut2108.woff2') format('woff2'), url('http://at.alicdn.com/t/font_1303894_e6bbqut2108.woff') format('woff'), url('http://at.alicdn.com/t/font_1303894_e6bbqut2108.ttf') format('truetype'), url('http://at.alicdn.com/t/font_1303894_e6bbqut2108.svg#iconfont') format('svg');
    }
    
    .iconfont {
        font-family: "iconfont" !important;
        font-size: 16px;
        font-style: normal;
    }
</style>

<body>
    <i class="iconfont">&#xe7bc;</i>
</body>

</html>

<i class="iconfont"></i>
i标签可以用其他标签替代,比如span,p(会换行)
class的名字可以自己定义
--图标的unicode标志

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="http://at.alicdn.com/t/font_1303894_e6bbqut2108.css">
    <title>Document</title>
</head>
<style>

</style>

<body>
    <i class="iconfont icon-chengshi"></i>
</body>

</html>

iconfont一定要加上,且名字不能变
icon-chengshi是图标对应的名字,要跟图标对应

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="http://at.alicdn.com/t/font_1303894_e6bbqut2108.js"></script>
    <title>Document</title>
</head>
<style>
    .icon {
        width: 1em;
        height: 1em;
        vertical-align: -0.15em;
        fill: currentColor;
        overflow: hidden;
    }
</style>

<body>
    <svg class="icon" aria-hidden="true">
            <use xlink:href="#icon-draw"></use>
    </svg>
</body>

</html>
上一篇 下一篇

猜你喜欢

热点阅读