CSS Menu width

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
Reaction score
13
I have a menu done in CSS that has a width of "X"

Now with all the menu's in the system, "X" is fine and it works perfectly. But as an "added feature" to the site I only want to display the menu's that actually have pages/items under those menu's. This of course means the width of "X" should be reduced accordingly.

Any ideas on how I can decrease the width of the menu based on the number of active menu items? Should I do something in JS (using jQuery) or should I just do a style override within the page that will override the style on the external CSS?
 
i'd suggest using jquery. even further i would suggest that use jq to determine the width of the menu(x) based on the screen size and reduce accordingly

so use jq to determine the nos of items in the <ul>, set x

you probably need to be looking into the child selectors...
 
With jquery you'd have to wait for the page to render first before being able to apply the necessary styles. I think the method I used (to override the main style width of the external css within the page itself) is sufficient enough.

Pages are designed to fit the standard average screen size used, so I work from that. I don't scale based on screen resolution
 
You are not a true developer are you? Cause a true developer would find the easiest and most effiencient way to accomplish a task - not the coolest way.

dont get me wrong - CSS is equally just as important,

rolflmao at your comment - development is an art, a skill, and you have to try different things that can accomplish the same objective otherwise you stagnate ...

is the coolest way always the best - probably not , but dammit dont you get a sense of pride and joy where achieving something doing completely against the status quo.. :D

if anything you learnt something and that for me trumps all
 
Did you define each width with a class selector? I ask cause im still learning
 
coding is a continual process of optimisation, refactoring and refining.
a good developer finds a way which requires the least hacks and exceptions so that the code is scalable for the next application.
which is why jquery, for example, is so quick to use.
 
Last edited:
Top
Sign up to the MyBroadband newsletter
X