Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7882829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:22:40+00:00 2026-06-03T04:22:40+00:00

I’m using twitter bootstrap and my nav bar works fine with collapse function. This

  • 0

I’m using twitter bootstrap and my nav bar works fine with collapse function.

This is my html code:

<div class="subnav">
    <ul class="nav nav-pills">
      <li class="dropdown">
        <a href="#" data-toggle="dropdown" class="dropdown-toggle">Buttons <b class="caret"></b></a>
        <ul class="dropdown-menu">
          <li class=""><a href="#buttonGroups">Button groups</a></li>
          <li class=""><a href="#buttonDropdowns">Button dropdowns</a></li>
        </ul>
      </li>
      <li class="dropdown">
        <a href="#" data-toggle="dropdown" class="dropdown-toggle">Navigation <b class="caret"></b></a>
        <ul class="dropdown-menu">
          <li class=""><a href="#navs">Nav, tabs, pills</a></li>
          <li class=""><a href="#navbar">Navbar</a></li>
          <li class=""><a href="#breadcrumbs">Breadcrumbs</a></li>
          <li class=""><a href="#pagination">Pagination</a></li>
        </ul>
      </li>
      <li class=""><a href="#labels">Labels</a></li>
      <li class=""><a href="#badges">Badges</a></li>
      <li class=""><a href="#typography">Typography</a></li>
      <li class=""><a href="#thumbnails">Thumbnails</a></li>
      <li class=""><a href="#alerts">Alerts</a></li>
      <li><a href="#progress">Progress bars</a></li>
      <li><a href="#misc">Miscellaneous</a></li>
    </ul>
  </div>

This is my bootstrap_and_overrides.css.scss

$iconSpritePath: asset-url('glyphicons-halflings.png', image);
$iconWhiteSpritePath: asset-url('glyphicons-halflings-white.png', image);
@import "bootstrap";
body { padding-top: 40px;
       .navbar .brand {padding: 10px 20px; }
       background: url("background.png") repeat scroll 0 0 #EEEEEE;


.subnav {
    background-color: #EEEEEE;
    background-repeat: repeat-x;
    border: 1px solid #E5E5E5;
    border-radius: 4px 4px 4px 4px;
    height: 36px;



            .nav > li > a {
                        border-left: 1px solid #F5F5F5;
                        border-radius: 0 0 0 0;
                        border-right: 1px solid #E5E5E5;
                        margin: 0;
                        padding-bottom: 11px;
                        padding-top: 11px;
                        }
    }

    .subnav-fixed {
    /*important part*/
    left: 0;
    position: fixed;
    right: 0;
    top: 40px;
    z-index: 1020;
    /*design stuff*/
    border-color: #D5D5D5;
    border-radius: 0 0 0 0;
    border-width: 0 0 1px;
    box-shadow: 0 1px 0 #FFFFFF inset, 0 1px 5px rgba(0, 0, 0, 0.1);
    background-color: #FFFFFF;
    }
}
@import "bootstrap-responsive";

and this is my js code:

$(document).scroll(function(){
    // If has not activated (has no attribute "data-top"
    if (!$('.subnav').attr('data-top')) {
        // If already fixed, then do nothing
        if ($('.subnav').hasClass('subnav-fixed')) return;
        // Remember top position
        var offset = $('.subnav').offset()
        $('.subnav').attr('data-top', offset.top);
    }

    if ($('.subnav').attr('data-top') - $('.subnav').outerHeight() <= $(this).scrollTop())
        $('.subnav').addClass('subnav-fixed');
    else
        $('.subnav').removeClass('subnav-fixed');
});

Also, I’m using subnav bar, my problem is that my subnav bar is not collapsed.

The correct subnav bar version in twitter bootstrap:

fine subnav twitter bootstrap

My bad version that it does not works fine :/

bad subnav twitter bootstrap

How can I fix this problem?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:22:41+00:00Added an answer on June 3, 2026 at 4:22 am

    If you have this problem, you can fix this problem with this:

    In your javascript file you must add this jquery code:

    //subnav config
     $(function(){
    
        var $win = $(window);
        var $nav = $('.subnav');
        var navTop = $('.subnav').length && $('.subnav').offset().top - 38;
        var isFixed = 0;
    
        processScroll();
    
        $win.on('scroll', processScroll);
    
        function processScroll() {
            console.log('test');
            var i, scrollTop = $win.scrollTop();
            if (scrollTop >= navTop && !isFixed) {
                isFixed = 1;
                $nav.addClass('subnav-fixed');
            } else if (scrollTop <= navTop && isFixed) {
                isFixed = 0;
                $nav.removeClass('subnav-fixed');
            }
        };
    })
    

    In your css file or in file bootstrap_and_overrides.css.scss you can add this code:

    /* Add additional stylesheets below
    -------------------------------------------------- */
    
    /* Subnav */
    .subnav {
      width: 100%;
      height: 36px;
      background-color: #eeeeee; /* Old browsers */
      background-repeat: repeat-x; /* Repeat the gradient */
      background-image: -moz-linear-gradient(top, #f5f5f5 0%, #eeeeee 100%); /* FF3.6+ */
      background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f5f5f5), color-stop(100%,#eeeeee)); /* Chrome,Safari4+ */
      background-image: -webkit-linear-gradient(top, #f5f5f5 0%,#eeeeee 100%); /* Chrome 10+,Safari 5.1+ */
      background-image: -ms-linear-gradient(top, #f5f5f5 0%,#eeeeee 100%); /* IE10+ */
      background-image: -o-linear-gradient(top, #f5f5f5 0%,#eeeeee 100%); /* Opera 11.10+ */
      filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#eeeeee',GradientType=0 ); /* IE6-9 */
      background-image: linear-gradient(top, #f5f5f5 0%,#eeeeee 100%); /* W3C */
      border: 1px solid #e5e5e5;
      -webkit-border-radius: 4px;
         -moz-border-radius: 4px;
              border-radius: 4px;
    }
    .subnav .nav {
      margin-bottom: 0;
    }
    .subnav .nav > li > a {
      margin: 0;
      padding-top:    11px;
      padding-bottom: 11px;
    
      border-right: 1px solid #e5e5e5;
      -webkit-border-radius: 0;
         -moz-border-radius: 0;
              border-radius: 0;
    }
    .subnav .nav > .active > a,
    .subnav .nav > .active > a:hover {
      padding-left: 13px;
      color: #777;
      background-color: #e9e9e9;
      border-right-color: #ddd;
      border-left: 0;
      -webkit-box-shadow: inset 0 3px 5px rgba(0,0,0,.05);
         -moz-box-shadow: inset 0 3px 5px rgba(0,0,0,.05);
              box-shadow: inset 0 3px 5px rgba(0,0,0,.05);
    }
    .subnav .nav > .active > a .caret,
    .subnav .nav > .active > a:hover .caret {
      border-top-color: #777;
    }
    .subnav .nav > li:first-child > a,
    .subnav .nav > li:first-child > a:hover {
      border-left: 0;
      padding-left: 12px;
      -webkit-border-radius: 4px 0 0 4px;
         -moz-border-radius: 4px 0 0 4px;
              border-radius: 4px 0 0 4px;
    }
    .subnav .nav > li:last-child > a {
      border-right: 0;
    }
    .subnav .dropdown-menu {
      -webkit-border-radius: 0 0 4px 4px;
         -moz-border-radius: 0 0 4px 4px;
              border-radius: 0 0 4px 4px;
    }
    
    
    /* Fixed subnav on scroll, but only for 980px and up (sorry IE!) */
    @media (min-width: 980px) {
      .subnav-fixed {
        position: fixed;
        top: 40px;
        left: 0;
        right: 0;
        z-index: 1020; /* 10 less than .navbar-fixed to prevent any overlap */
        border-color: #d5d5d5;
        border-width: 0 0 1px; /* drop the border on the fixed edges */
        -webkit-border-radius: 0;
           -moz-border-radius: 0;
                border-radius: 0;
        -webkit-box-shadow: inset 0 1px 0 #fff, 0 1px 5px rgba(0,0,0,.1);
           -moz-box-shadow: inset 0 1px 0 #fff, 0 1px 5px rgba(0,0,0,.1);
                box-shadow: inset 0 1px 0 #fff, 0 1px 5px rgba(0,0,0,.1);
        filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); /* IE6-9 */
      }
      .subnav-fixed .nav {
        width: 100%;
        margin: 0 auto;
        padding: 0 1px;
        background-color: #FFFFFF;
      }
      .subnav .nav > li:first-child > a,
      .subnav .nav > li:first-child > a:hover {
        -webkit-border-radius: 0;
           -moz-border-radius: 0;
                border-radius: 0;
      }
    }
    
    
    @media (max-width: 768px) {
    
      /* Subnav */
      .subnav {
        position: static;
        top: auto;
        z-index: auto;
        width: auto;
        height: auto;
        background: #fff; /* whole background property since we use a background-image for gradient */
        -webkit-box-shadow: none;
           -moz-box-shadow: none;
                box-shadow: none;
      }
      .subnav .nav > li {
        float: none;
      }
      .subnav .nav > li > a {
        border: 0;
      }
      .subnav .nav > li + li > a {
        border-top: 1px solid #e5e5e5;
      }
      .subnav .nav > li:first-child > a,
      .subnav .nav > li:first-child > a:hover {
          -webkit-border-radius: 4px 4px 0 0;
             -moz-border-radius: 4px 4px 0 0;
                  border-radius: 4px 4px 0 0;
      }
    
    
    }
    

    if this code is valid for you, please accept the answer and gives positive feedback to this response. I hope helps.

    Thank you very much.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.