0

我用 harp.js 创建了基本的静态网站项目。项目确实成功编译,没有错误,我已经为引导程序 4 添加了所需的文件和依赖项。问题是我的模板布局没有正确呈现。

这是我的布局html。

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <title></title>
</head>
    <body>
<%- partial("partial/_header") %>
    <%- yield %>
        <%- partial("partial/_footer") %>
<script src="http://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
                    crossorigin="anonymous"></script>
                <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ"
                    crossorigin="anonymous"></script>
                <script src="/js/bootstrap.min.js"></script>
</body>

_header 部分视图 html

<nav class="navbar navbar-light bg-faded">
    <a class="navbar-brand" href="#">Learning Bootstrap 4</a>
    <ul class="nav navbar-nav">
        <li class="nav-item active">
            <a class="nav-link" href="index.html">Home</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="about.html">About</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="contact.html">Contact</a>
        </li>
    </ul>
    <form class="form-inline pull-xs-right">
        <input class="form-control" type="text" placeholder="Search">
        <button class="btn btn-primary" type="submit">Search</button>
    </form>
</nav>

我在每个浏览器中都得到相同的输出。 这是输出

JsFiddle 的问题 可以指出我做错了什么吗?

4

1 回答 1

1

你错过navbar-expand了导航元素。检查更新的小提琴: https ://jsfiddle.net/cjhnsouf/2/

<nav class="navbar navbar-expand navbar-light bg-faded">
      <a class="navbar-brand" href="#">Learning Bootstrap 4</a>
      <ul class="nav navbar-nav">
        <li class="nav-item active">
          <a class="nav-link" href="index.html">Home</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="about.html">About</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="contact.html">Contact</a>
        </li>
      </ul>
      <form class="form-inline pull-xs-right">
        <input class="form-control" type="text" placeholder="Search">
        <button class="btn btn-primary" type="submit">Search</button>
      </form>
</nav>
于 2018-04-27T07:03:54.467 回答