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 6070513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:56:32+00:00 2026-05-23T09:56:32+00:00

Alright, so here is the situation… Say I have a navbar for a site,

  • 0

Alright, so here is the situation…

Say I have a navbar for a site, and I allow users to change the number of links they want on this navbar. This means they could have 3, 5, 10, etc.

What I want to do is make it so that if one link is up, it only takes up, say, 1/5th of the space on the navbar. If I weren’t using borders, I might do something like:

width: 18%;
padding: 0 1%;

However, I have two problems with this:

1) For 4 buttons, that’s fine that it doesn’t fill up the whole row. It would look ugly if the links were too wide… but when I have 6 or 7 buttons, it’s got huge overflow!
2) Since I have borders, I can’t use a percentage value for the borders or the widths, because I can’t properly estimate how much of the percentage it will be.

Now, I know I don’t have to use percentage values, but what I would ideally prefer is that the first button is the smallest possible size necessary for all the other buttons to fit properly, meaning that if I have 950px and 6 links, the first link can be about 150px while the others are 160px… that’s fine. I want all the other buttons on the navbar to be equally sized, regardless of how many links there are.

I also need for it to accept a border… I figure the way to do this is to put a border in the nested div, so that way it doesn’t effect the overall width of the button? This is all well and good, but I’m still plagued by the issue of not being able to design a dynamic site using the style I want if I can’t get all the nav buttons to fit the width properly.

Are there some js tricks I could use? I don’t even know…

Thanks

Edit: Here is my demo fiddle

  • 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-23T09:56:32+00:00Added an answer on May 23, 2026 at 9:56 am

    A pure CSS solution, based on justification of the links, though still as semantic list items:

    See demo fiddle.

    Tested on W7 in IE7, IE8, IE9, Chrome 12, SafariWin 5, Opera 11, FF 4.

    Update:

    Concerning the width: Since you dynamically inject the navigation links into the HTML page, it likely is also possible to classify the navigation bar style.

    See updated fiddle.

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

Sidebar

Related Questions

Alright here is the thing, I have this site that was once wordpress but
Alright here's the situation, I have an application written in the Zend_Framework, that is
Alright, so here's what I'm trying to do. Let's say I have the following
Alright here it is. Simply, I want to be able to have the background
Alright so here is the question. I have a user class which contains a
Alright, here goes. I'm making a very basic app, and I want the user
Alright, Here's the gist of what I'm planning to do. I'm going to have
Alright, so here is the property I have public List<String> names{ get{ lock(_names) return
Alright, here's an odd one from an MS Access database I'm running. I have
Alright, here we go. I have a cocos2d app, and there are targets that

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.