Font Awesome 图标未出现

问题描述 投票:0回答:2

我见过几个人描述了类似的问题,但我所看到或尝试过的都没有解决我的问题。我在本地存储 Font Awesome 5 文件,但是当我尝试添加一些图标时,它们不会出现在浏览器中。我尝试了多种浏览器,结果都相同。我怀疑错误在于我配置 CSS 文件的方式,或者我需要将另一个 FA 文件添加到我的本地计算机,但我无法证明这些假设中的任何一个。下面的代码片段不起作用,因为我正在运行 xampp 并在本地存储文件,所以我还附加了最大窗口和较小窗口的一些图像。

较小的窗口:

最大窗口:

文件位置:

/*General Styles */

body {
    font-family: "Roboto", Helvetica, Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.42857143;
    color: #333333;
    background-color: #f0f0f0;
    overflow-x: hidden;
}

/*Top Navbar Styles*/
#top{
    background: #555555;
    padding: 10px 0;
}

#top.offer{
    text-transform: uppercase;
    color: #ffff;
}

#top.offer.btn{
    text-transform: uppercase;
}

@media (max-width: 991px) {
    #top.offer{
        margin-bottom: 10px;   
    }
}

@media (max-width: 991px){
    #top{
        font-size: 12px;
        text-align: center;
    }
}

#top a {
    color: #fff;
}

#top ul.menu{
    padding-top: 5px;
    margin: 0;
    text-align: right;
    font-size: 12px;
    list-style: none;
}

@media (max-width: 991px){
    #top ul.menu{
        text-align: center;
    }
}

#top ul.menu > li{
    display: inline-block;
}

#top ul.menu > li a{
    color: #eeeeee;
}

#top ul.menu > li + li:before{
    content: "|\00a0";
    padding: 0 5px;
    color: #f7f7f7;
}
<!DOCTYPE html>
<html>
<head>
    <title>E Commerce Store</title>

    <link href="http://fonts.googleapis.com/css?family=Roboto:400,500,700,300,100" rel="stylesheet">
    <link href="styles/bootstrap.min.css" rel="stylesheet">
    <link href="styles/style.css" rel="stylesheet">
    <link href="font-awesome/css/fontawesome.min.css" rel="stylesheet">

</head>
<body>
    <div id="top"><!--top start -->
        <div class="container"><!-- container start -->
            <div class="col-md-6 offer"><!-- col md-6 offer start -->
                <a href="#" class="btn btn-success btn-sm">Welcome : Guest </a>
                <a href="#" >Shopping Cart Total Price: $100, Total Items 2 </a>
            </div><!-- col md-6 offer end -->
            <div class="col-md-6"><!-- col md-6 start -->
                <ul class="menu"><!-- menu start -->
                    <li><a href="customer_register.php">Register</a></li>
                    <li><a href="checkout.php">My Account</a></li>
                    <li><a href="cart.php">Go to Cart</a></li>
                    <li><a href="checkout.php">Login</a></li>
                </ul><!-- menu end -->
            </div><!-- col md-6 end -->
        </div><!-- container end -->
    </div> <!-- top end -->

    <div class="navbar navbar-default" id="navbar"><!-- navbar navbar-default start -->
        <div class="container"><!-- container start -->
            <div class="navbar-header"><!-- navbar-header start -->
                <a class="navbar-brand home" href="index.php">
                    <img src="images/logo.png" alt="company logo" class="hidden-xs">
                    <img src="images/logo-small.png" alt="company logo" class="visible-xs">
                </a>
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigation">
                    <span class="sr-only">Toggle Navigation</span><i class="fas fa-align-justify"></i>
                </button>
                <button type="button" class="navbar-toggle" data-toggle="navbar-toggle" data-target="#search">
                    <span class="sr-only">Toggle Search</span><i class="fas fa-search"></i>
                </button>
            </div><!-- navbar-header end -->

            <div class="navbar-collapse collapse" id="navigation"><!-- navbar-collapse collapse start -->
                <div class="padding-nav" ><!-- padding-nav start -->
                    <ul class="nav navbar-nav navbar-left"><!-- nav navbar-nav navbar-left start -->
                        <li class="active"><a href="index.php">Home</a></li>
                        <li><a href="shop.php">Shop</a></li>
                        <li><a href="checkout.php">My Account</a></li>
                        <li><a href="cart.php">Shopping Cart</a></li>
                        <li><a href="contact.php">Contact Us</a></li>
                    </ul><!-- nav navbar-nav navbar-left start -->
                </div><!-- padding-nav end -->
                <a class="btn btn-primary navbar-btn right" href="cart.php"><i class="fas fa-shopping-cart"></i><span>4 items in cart</span></a>
                <div class="navbar-collapse collapse right"><!-- navbar-collapse collapse right start -->
                    <button class="btn navbar-btn btn-primary" type="button" data-toggle="collapse" data-target="#search"><span class="sr-only">Toggle Search</span><i class="fas fa-search"></i></button>
                </div><!-- navbar-collapse collapse right end -->


            </div><!-- navbar-collapse collapse end -->
        </div><!-- container end -->
    </div><!-- navbar navbar-default end -->

<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>

</body>
</html>

html css font-awesome
2个回答
6
投票

通过 CDN 使用

fontawesome.min.css
时,您的任何图标都不会呈现。当使用
all.min.css
时,他们都会这样做。

使用

"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/fontawesome.min.css"
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.min.css"

进行测试

工作小提琴 不工作的小提琴


0
投票

不,它仍然没有解决问题,有人可以帮助我吗?

© www.soinside.com 2019 - 2024. All rights reserved.