Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am editing the following master page which my current SharePoint site is using (I am using SharePoint 2007 + Windows Server 2008),

http://www.mediafire.com/file/mmvj5ijgm3j/BlueBand.master

Currently, I am using the hard-coded value "120" to set the width of the left navigation bar, here is the related code in the master file. How do I set the width of left navigation bar to be automatically changed according to the max length of items on left navigration bar?

<SharePoint:AspMenu ID="CurrentNav" width="120" runat="server" datasourceID="SiteMapDS" orientation="Vertical" StaticDisplayLevels="2" MaximumDynamicDisplayLevels="0" StaticSubMenuIndent="1" ItemWrap="true" AccessKey="3" CssClass="leftNav" SkipLinkText="<%$Resources:cms,masterpages_skiplinktext%>">
share|improve this question
    
Thanks for making the title more readable, Alex! –  George2 Nov 8 '09 at 9:12
add comment

1 Answer

You might want to do this with jQuery on the client side. The trick will be to determine the number of pixels wide required per character given your font family and size choice. Depending on how you are setting your font sizes, you may be able to take advantage of ems, but that would assume that characters are on average as wide as they are tall, which may not be the case with the font family you have chosen.

M.

share|improve this answer
    
Marc, thanks! jQuery is new to me, any related reference samples? –  George2 Nov 8 '09 at 18:16
    
I don't think I have a jQuery example, but here's a sort of related example in which I dynamically set the width of multi-select boxes on a form with JavaScript: mdasblog.wordpress.com/2008/12/30/… The logic would be similar, but the jQuery would be simpler. M. –  Marc D Anderson Nov 9 '09 at 19:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.