/    Sign up×
Community /Pin to ProfileBookmark

Expanding nav boxes to fill a horizontal space?

Hello. I have a rather unique problem.

I have a top navigation that are several boxes floating left. The body container has a set width of 800px. The different navigational items are boxes that fill the space horizontally. This is used by setting fixed widths on each box.

However, if a nav item is removed, a white space appears on the right (naturally). What I’d like to do is be able to somehow automatically adjust the elements to fill the space, regardless of how many items there are.

Is there an easy way to do this? Javascript, maybe?

dep

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@afigueroaMar 14.2008 — are the box's widths set?

if they are, try getting rid of the width property.
Copy linkTweet thisAlerts:
@KDLAMar 14.2008 — Omitting the width would only make each box expand to fill the parent container, meaning that you'd have several boxes 800px wide.

Are you wanting them centered, or aligned left/right? You could set the container to text-align: center; and then a background the same color as the boxes which would "fake" the stretch.

KDLA
×

Success!

Help @dep spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...