简体   繁体   中英

Twitter bootstrap Navbar justified links with logo/brand

I cant seem to justify my links and have my logo in the navbar. My links and logo will overlap on the left hand side. I want to make it so my links will justify to the right of my logo.

%body
   %nav.navbar.navbar-inverse.navbar-fixed-top
     .container-fluid
       .navbar-header
         %button.navbar-toggle.collapsed{"aria-controls" => "navbar", "aria-expanded" => "false", "data-target" => "#navbar", "data-toggle" => "collapse", :type => "button"}
        %span.sr-only Toggle navigation
        %span.icon-bar
        %span.icon-bar
        %span.icon-bar
  .container-fluid
    .navbar-header
      %a.navbar-brand{:href => "#"}
        %img{:alt => "IMage", :height => "50", :src => "/assets/logo.png"}

      %ul.nav.navbar-nav.nav-justified
        %li
          %a{:href => "#"} link 
        %li
          %a{:href => "#"} Link
        %li
          %a{:href => "#"} link
        %li
          %a{:href => "#"} link
        %li
          %a{:href => "#"} link
        %li
          %a{:href => "#"} link
        %li
          %a{:href => "#"} link 
        %li
          %a{:href => "#"} link   

css

.navbar {
   position: relative;
   background-color: #004170;
   padding-top: 15px;
   padding-bottom: 15px;
   margin-bottom: 0;
   font-size: 18px;

}

.navbar-nav.nav-justified > li{
   float:none;
}

Try remove .navbar-nav class from navbar code.

%ul.nav.navbar-nav.nav-justified

to

%ul.nav.nav-justified

If your navigation slightly move down then you can set below properties :

.nav-justified {
  width: 98%;
}
.nav-justified > li {
  float: none;
}

It works for me.

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