我们如何在 CSS 中使用 Font Awesome 图标?我想在标题后显示一个图标

How can we use Font Awesome Icon in CSS? I want to display an icon after heading

我们如何在CSS中使用Font Awesome Icon?我想在标题后显示一个图标。 我想稍微自定义一下标题,以便标题后有一个图标。

这是我的代码

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

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css"
        integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous" />

    <title>Test</title>

    <style>
        * {
            margin: 0;
            padding: 0%;
            box-sizing: border-box;
        }

        .main-div {
            width: 100vw;
            height: 100vh;
            padding-top: 100px;
            text-align: center;
        }

        h1 {
            color: #2980b9;
            font-size: 5rem;
        }

        h1::after {
            font-family: "Font Awesome 5 Free";
            font-weight: 900;
            content: "\f007";
            width: 20vh;
            height: 25px;
            color: #1abc9c;
            font-size: 3rem;
            display: inline-block;
            margin: 0 auto;
        }
    </style>
</head>

<body>
    <section class="main-div">
        <h1>Test</h1>
    </section>
</body>

</html> 

但是,图标没有显示。另外,如何使用 css?

显示该图标

非常感谢任何帮助!

您可以将 Font Awesome 5 Free 替换为 Font Awesome 5 Pro

你的代码看起来像这样:

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

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css"
        integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous" />

    <title>Test</title>

    <style>
        * {
            margin: 0;
            padding: 0%;
            box-sizing: border-box;
        }

        .main-div {
            width: 100vw;
            height: 100vh;
            padding-top: 100px;
            text-align: center;
        }

        h1 {
            color: #2980b9;
            font-size: 5rem;
        }

        h1::after {
            font-family: "Font Awesome 5 Pro";
            font-weight: 900;
            content: "\f007";
            width: 20vh;
            height: 25px;
            color: #1abc9c;
            font-size: 3rem;
            display: inline-block;
            margin: 0 auto;
        }
    </style>
</head>

<body>
    <section class="main-div">
        <h1>Test</h1>
    </section>
</body>

</html>