提问者:小点点

字体Awesome图标在HTML中不起作用


我一直在开发一个Javascript待办事项应用程序,其中包含了一些来自Font Awesome的图标。 但他们就是不来。 到目前为止我已经试过了:

  1. 禁用adblockers并重新加载页面
  2. 试用不同的浏览器。
  3. 删除CDN并在项目中使用Font Awesome CSS本身。

我已经谷歌关于这个问题,再次检查我的CDN链接,检查最近的文件和一切似乎都好。 我做错了什么?

我在下面附上了HTML代码片段和浏览器的截图。

null

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
    <link href="https://fonts.googleapis.com/css2?family=Open+Sans&family=Poppins:wght@300&family=Roboto&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="style.css">
    <title>To do List</title>
</head>
<body>
    <header>
        <h1>My todo list</h1>
    </header>
    
    <form>
        <input type="text" class="todo-input">
        <button class="todo-button" type="submit">
            <i class="fas fa-user-md"></i>
        </button>
        <div class="select">
            <select name="todos" class="filter-todo">
                <option value="all">All</option>
                <option value="completed">Completed</option>
                <option value="uncompleted">Uncompleted</option>
            </select>
        </div>
    </form>

    <div class="todo-container">
        <ul class="todo-list"></ul>
    </div>
    
    <script src="app.js"></script>
</body>
</html>

null

浏览器视图


共1个答案

匿名用户

fas fa-user-md更改为fa fauser-md,并将其直接添加到按钮中。

像这样-

null

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
    <link href="https://fonts.googleapis.com/css2?family=Open+Sans&family=Poppins:wght@300&family=Roboto&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="style.css">
    <title>To do List</title>
</head>
<body>
    <header>
        <h1>My todo list</h1>
    </header>
    
    <form>
        <input type="text" class="todo-input">
        <button class="todo-button fa fa-user-md" type="submit">
        </button>
        <div class="select">
            <select name="todos" class="filter-todo">
                <option value="all">All</option>
                <option value="completed">Completed</option>
                <option value="uncompleted">Uncompleted</option>
            </select>
        </div>
    </form>

    <div class="todo-container">
        <ul class="todo-list"></ul>
    </div>
    
    <script src="app.js"></script>
</body>
</html>