无法使用 font-awesome 在 html 代码中加载主页图标

发布于 2025-01-15 05:36:13 字数 1023 浏览 1 评论 0原文

<!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" />
        <title>WEbsite</title>
    
        <link rel="stylesheet" href="css/style.css" />
        <link
          rel="stylesheet"
          href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.0/css/all.min.css"
        />
      </head>
    
      <body>
        <header class="header">
          <nav class="nav-bar">
              <a href="#home"><i class="fa-regular fa-house"></i>  <span>home</span></a>
          </nav>
        </header>
      </body>
    </html>

无法使用 font-awesome 在 html 代码中加载主页图标。浏览器显示十字图标,代替主页图标。请告诉我代码有什么问题?

<!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" />
        <title>WEbsite</title>
    
        <link rel="stylesheet" href="css/style.css" />
        <link
          rel="stylesheet"
          href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.0/css/all.min.css"
        />
      </head>
    
      <body>
        <header class="header">
          <nav class="nav-bar">
              <a href="#home"><i class="fa-regular fa-house"></i>  <span>home</span></a>
          </nav>
        </header>
      </body>
    </html>

Unable to load home icon in html code using font-awesome. In place of home icon, browser showing a cross icon. Kindly, tell me what's wrong with the code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

温柔女人霸气范 2025-01-22 05:36:13

使用 fa-solid 代替常规。

<!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" />
  <title>WEbsite</title>

  <link rel="stylesheet" href="css/style.css" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.0/css/all.min.css" />
</head>

<body>
  <header class="header">
    <nav class="nav-bar">
      <a href="#home"><i class="fa-solid fa-house"></i>  <span>home</span></a>
    </nav>
  </header>
</body>

</html>

Use fa-solid instead of regular.

<!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" />
  <title>WEbsite</title>

  <link rel="stylesheet" href="css/style.css" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.0/css/all.min.css" />
</head>

<body>
  <header class="header">
    <nav class="nav-bar">
      <a href="#home"><i class="fa-solid fa-house"></i>  <span>home</span></a>
    </nav>
  </header>
</body>

</html>

缱绻入梦 2025-01-22 05:36:13

Fontawesome 图标加载正常,但您使用了错误的类。
代替


The Fontawesome icon is loaded fine, but you're using the wrong classes.
Replace
<i class="fa-regular fa-house"></i>
to
<i class="fa fa-house"></i>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文