字体真棒未在Bootstrap 4 navbar-brand中显示

时间:2018-08-01 05:08:54

标签: css bootstrap-4 font-awesome

我正在尝试建立一个本地Laravel网站,以了解Laravel 5.6的新功能和差异。但是,当尝试在Bootstrap 4的navbar-brand中放置“真棒字体”图标时,似乎无法加载。当我在Chrome的检查器中检出元素时,元素尺寸为0x0。我尝试添加90px的宽度和高度只是为了查看图标,但它仍然不会显示。有什么想法吗?

<!DOCTYPE html>
<html>
<head>
    <title>App</title>
    <link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
    <link rel="stylesheet" href="{{ asset('css/app.css') }}">
</head>
<body>

<!-- NAVBAR -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <a href="{{ route('/') }}" class="navbar-brand">
        <i class="fa fa-laptop-code"></i>
    </a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsedContent">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="collapsedContent">
        <ul class="navbar-nav">
            <li class="nav-item active">
                <a href="{{ Auth::check() ? route('home') : route('/') }}" class="nav-link">Home</a>
            </li>
        </ul>
    </div>
</nav>
<!-- NAVBAR -->


<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</body>
</html>

3 个答案:

答案 0 :(得分:4)

fa-laptop-code在您正在加载的font-awesome版本中不可用。

您正在加载4.7,但如果要使用该图标,则需要加载FontAwesome 5

改为使用以下CDN:https://use.fontawesome.com/releases/v5.2.0/css/all.css

答案 1 :(得分:1)

尝试一下,它将起作用

<i class="fa fa-laptop"></i>

答案 2 :(得分:1)

<!DOCTYPE html>
<html>
<head>
    <title>App</title>
    <link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
    <link rel="stylesheet" href="{{ asset('css/app.css') }}">
</head>
<body>

<!-- NAVBAR -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <a href="{{ route('/') }}" class="navbar-brand">
        <i class="fa fa-laptop"></i>
    </a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsedContent">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="collapsedContent">
        <ul class="navbar-nav">
            <li class="nav-item active">
                <a href="{{ Auth::check() ? route('home') : route('/') }}" class="nav-link">Home</a>
            </li>
        </ul>
    </div>
</nav>
<!-- NAVBAR -->


<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</body>
</html>