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

  • Home
  • SEARCH
  • 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 6147711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:09:06+00:00 2026-05-23T19:09:06+00:00

I have a horizontal navigation bar. Each button is a span with a background

  • 0

I have a horizontal navigation bar. Each “button” is a span with a background color and some other CSS set, that when clicked uses jQuery to present a stylized <ul>/<li> drop-down menu. Each button span also contains an icon created with a normal <img>. My page layout is fluid.

My top nav’s width isn’t too wide in general, but I want to be able to handle cases where it doesn’t quite fit. An elegant solution I’d like to implement involves “collapsing” the nav bar if it is too wide. Let me know what you want I mean:

Full Nav Width:

Full Nav Width

Partially Collapsed:

Partially Collapsed

Fully Collapsed:

Fully Collapsed

Basically, as the width of the nav’s container shrinks, I would like the right-most button’s text to vanish, shrinking to display just the icon. If the nav’s container were even smaller, the next button would shrink as well. This would continue as long as it was necessary, but I typically only expect the outer button or two to have to collapse in this manner. You might recognize similar behavior on the ribbon control within later versions of Microsoft Office.

How can I implement such behavior in a clean and compatible manner?

Note that I am not opposed to completely changing these elements around. I am only using <span> for the buttons, as that is what I started with. If they need to be something different, that is fine with me.

Each button looks like this:

<span class="menu_head" id="mnuButton">Button Name<img src="icon.png" alt="Button Name" /></span>

You can find a JSFiddle of what I have now here: http://jsfiddle.net/9FwP7/1

  • 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-05-23T19:09:07+00:00Added an answer on May 23, 2026 at 7:09 pm

    This worked for me, assuming #menu is the container, and the menu item looks like this:

    <div id="menu">
        <span class="menu_head" id="mnuButton1"><span>Button Name</span><img src="http://dummyimage.com/20x20/000/fff" alt="Button Name" /></span>
        <span class="menu_head" id="mnuButton2"><span>Button Name</span><img src="http://dummyimage.com/20x20/000/fff" alt="Button Name" /></span>
        <span class="menu_head" id="mnuButton3"><span>Button Name</span><img src="http://dummyimage.com/20x20/000/fff" alt="Button Name" /></span>
        <span class="menu_head" id="mnuButton3"><span>Button Name</span><img src="http://dummyimage.com/20x20/000/fff" alt="Button Name" /></span>
        <span class="menu_head" id="mnuButton4"><span>Button Name</span><img src="http://dummyimage.com/20x20/000/fff" alt="Button Name" /></span>
    </div>
    

    The jQuery (this could be changed to trigger on resize()):

        $(function () {
            // get total number of menu items
            var no_menu_items = $('.menu_head').length;
            var incrementer = 0;
            for (var i = 0; i < no_menu_items; i++) {
                // add the width of the current menu item
                incrementer += $('.menu_head').eq(i).width();
                if ($('#menu').width() < incrementer) {
                    $('.menu_head').eq(i).find('span').hide();       
                }   
            }        
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have the following CSS in place to display a horizontal navigation bar
Trying to have a horizontal navigation bar that has equally spaced links spanning across
In Silverlight, I have a Vertical ListBox that has a Horizontal ListBox for each
can someone please recommend a horizontal navigation bar with a horizontal second tier that
I have a horizontal css menu with 5 items. e.g 1) Home 2) Users
I have a UIScrollView that shows vertical data, but where the horizontal component is
I've got a tabbed navigation bar where I'd like the open tab to have
Imagine I have a navigation bar in my page header, with a number of
I have a horizontal navigation menu which I can edit the source of, my
I'm trying to create a basic navigation and I'd like to have a horizontal

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.