使用CSS3伪元素引入阿里巴巴的字体图标

使用CSS3伪元素引入阿里巴巴的字体图标

字体图标引入的多种方式

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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 1.需要引入文件 -->
    <link rel="stylesheet" href="./iconfont/iconfont.css">
    <style>
        @font-face {
            font-family: 'iconfont';
            src: url('iconfont.eot');
            src: url('iconfont.eot?#iefix') format('embedded-opentype'),
                url('iconfont.woff2') format('woff2'),
                url('iconfont.woff') format('woff'),
                url('iconfont.ttf') format('truetype'),
                url('iconfont.svg#iconfont') format('svg');
        }

        .icon {
            width: 1em;
            height: 1em;
            vertical-align: -0.15em;
            fill: currentColor;
            overflow: hidden;
        }

        div {
            position: relative;
            width: 150px;
            height: 20px;
            margin: 100px auto;
            border: 1px solid red;
        }

        /* 实现使用伪元素显示一个图标字体 */
        div::after {
            position: absolute;
            /* 调整定位位置 */
            right: 5px;
            color: blue;
            font-size: 18px;
            /* 引入方式 */
            /* 字体编码在 html 中是 &#xe614; ,在 css 中是 \e614 */
            content: '\e614';
            /* 引入字体 */
            font-family: 'iconfont';
        }
    </style>
</head>

<body>
    <!-- 通过伪元素实现输入框显示一个图标 -->
    <div class="iconfont"></div>
</body>

</html>
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值