导航栏折叠按钮无法用于某些视图

时间:2018-05-22 22:48:55

标签: html css node.js twitter-bootstrap twitter-bootstrap-3

navbar-collapse 按钮不适用于某些观看次数。

  • 适用于 index.html blogs.html
  • 它不适用于 blog1.html

我怀疑它必须对路径查找做些什么。

main/views内的每个视图都能正常运行。

但是main/views/blogs/内的每个视图都不起作用。

我将node.js源设置为:

main
main/public/index.html
main/views/blogs.html
main/views/blogs/blog1.html
main/public/css/bootstrap.min.css
main/public/css/custom.css

节点app.js

app.get('/blogs', function (req, res) {
  res.render('blogs.html',
  { title : '' }
  )
})

app.get('/blogs/:id', function (req, res) {
  var id = req.params.id;
  res.render('blogs/' + id + '.html',
  { title : '' }
  )
});

主题元素blogs.html

  <link href="css/bootstrap.min.css" rel="stylesheet">
  <link href="css/custom.css" rel="stylesheet">

主题元素blog1.html

  <link href="/css/bootstrap.min.css" rel="stylesheet">
  <link href="/css/custom.css" rel="stylesheet">

导航栏元素blogs.html

    <div class="navbar navbar-static-top" role="navigation">
     <div class="container">
        <div class="navbar-header">
           <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
           <span class="sr-only">Toggle navigation</span>
           <span class="icon-bar"></span>
           <span class="icon-bar"></span>
           <span class="icon-bar"></span>
           </button>
           <a class="navbar-brand" href="/"  style="font-family: 'Arial Rounded MT Bold'"><img id="logo" src="img/logo.png">TymeIt<small></small></a>
        </div>
        <div class="navbar-collapse collapse">
           <ul style="font-family:futura;font-size:18px" class="nav navbar-nav navbar-right">
              <li><a href="/about">About</a></li>
              <li><a href="/blogs">Blogs</a></li>
              <li><a href="/videos">Videos</a></li>
              <li><a href="#contact" class="page-scroll">Contact</a></li>
           </ul>
        </div>
        <!--/.nav-collapse -->
     </div>
    </div>

导航栏元素blog1.html

    <div class="navbar navbar-static-top" role="navigation">
     <div class="container">
        <div class="navbar-header">
           <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
           </button>
           <a class="navbar-brand" href="/" style="font-family: 'Arial Rounded MT Bold'"><img id="logo" src="/img/logo.png">TymeIt<small></small></a>
        </div>
        <div class="navbar-collapse collapse">
           <ul style="font-family:futura;font-size:18px" class="nav navbar-nav navbar-right">
              <li><a href="/about">About</a></li>
              <li><a href="/blogs">Blogs</a></li>
              <li><a href="/videos">Videos</a></li>
              <li><a href="#contact" class="page-scroll">Contact</a></li>
           </ul>
        </div>
     </div>
    </div>


  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
  <script src="js/vendor/holder.min.js"></script>
  <script src="js/bootstrap.min.js"></script>

你能帮我解决这个问题吗?

0 个答案:

没有答案