简体   繁体   中英

Why are my Twitter Bootstrap navbar styles not applying?

Some background -I am making a rails app (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. Other bootstrap styles work display just fine, such as .btn-group, .btn-primary, etc. Here is a navbar I am trying to create (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/

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. Any help would be appreciated!

You are using old (2.x) markup with new styles. Proper markup, as taken from Bootstrap docs :

<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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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