简体   繁体   English

为什么我的Twitter Bootstrap导航栏样式不适用?

[英]Why are my Twitter Bootstrap navbar styles not applying?

Some background -I am making a rails app (4.0). 一些背景-我正在制作Rails应用程序(4.0)。 Using BS3, bootstrap.css and bootstrap-theme.css are both in my project's stylesheets directory, as well as bootstrap.js in my javascripts directory. 使用BS3,bootstrap.css和bootstrap-theme.css都在我项目的stylesheets目录中,而bootstrap.js都在我的javascripts目录中。 Other bootstrap styles work display just fine, such as .btn-group, .btn-primary, etc. Here is a navbar I am trying to create (HAML): 其他引导样式也可以正常显示,例如.btn-group,.btn-primary等。这是我要创建的导航栏(HAML):

.navbar.navbar-fixed-top
    .navbar-inner
        .container
            %a.brand{:href => '#'} Site Name
            %ul.nav
                %li.active
                    %a{:href => '#'} Home
                %li
                    %a{:href => '#'} Link 1
                %li
                    %a{:href => '#'} Link 2

And here is how it looks, vertically stacked instead of horizontal, as well as the 'brand' missing its styles: http://jsfiddle.net/JLt9u/ 这是它的外观,垂直堆叠而不是水平堆叠,以及缺少其样式的“品牌”: http//jsfiddle.net/JLt9u/

How do I make it horizontal, as seen on the site? 如现场所见,如何使它水平? Am I simply using outdated class names? 我只是在使用过时的类名吗? I've looked at all sorts of other questions on SO related to this and none seem to have the answer. 我已经看过与SO相关的各种其他问题,但似乎没有答案。 Any help would be appreciated! 任何帮助,将不胜感激!

You are using old (2.x) markup with new styles. 您正在使用具有新样式的旧(2.x)标记。 Proper markup, as taken from Bootstrap docs : 正确的标记,取自Bootstrap文档

<nav class="navbar navbar-default navbar-fixed-top">
  <ul class="nav navbar-nav">
    <li class="active"><a href="#">Home</a></li>
    <li><a href="#">Link 1</a></li>
    <li><a href="#">Link 2</a></li>
  </ul>
</nav>

If you are migrating from 2.x to 3.0 there is a docs section for that . 如果您是从2.x迁移到3.0,则有一个docs部分

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM