字体图标结合伪元素的使用

字体图标结合伪元素的使用


代码:

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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        @font-face {
            font-family: 'icomoon';
            src: url('fonts/icomoon.eot?sz2z9h');
            src: url('fonts/icomoon.eot?sz2z9h#iefix') format('embedded-opentype'),
                url('fonts/icomoon.ttf?sz2z9h') format('truetype'),
                url('fonts/icomoon.woff?sz2z9h') format('woff'),
                url('fonts/icomoon.svg?sz2z9h#icomoon') format('svg');
            font-weight: normal;
            font-style: normal;
            font-display: block;
        }

        .search {
            width: 250px;
            height: 35px;
            border: 1px solid #ccc;
        }

        .search::after {
            font-family: 'icomoon';
            content: '\e986';
        }
    </style>
</head>

<body>
    <div class="search">搜索</div>
</body>

</html>

效果图:

最基本的显示,未作任何调整

在这里插入图片描述

发布了11 篇原创文章 · 获赞 0 · 访问量 449

猜你喜欢

转载自blog.csdn.net/qq_36323561/article/details/105087216