JavaScript
  Home arrow JavaScript arrow Page 4 - Using the YUI Menu Control
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Using the YUI Menu Control
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 16
    2007-05-02

    Table of Contents:
  • Using the YUI Menu Control
  • Creating a Basic Menu
  • Rendering and Displaying the Menu
  • Changing the Styling

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using the YUI Menu Control - Changing the Styling


    (Page 4 of 4 )

    Once you've added any applicable sub-menus to your menu, you can also very easily change the styling to fit in with your existing or desired site theme. You can create and use your own style sheet if you wish, but I have found it far easier to edit the style properties found in menu.css instead of creating a new style sheet. For example, you can make the text of your menu and sub-menus bold just by adding the font-weight:bold; rule to the div.yuimenu selector at the very top of the file. You could also take away the underlining text-decoration property when a menu item is rolled over by changing the underline property to none in the div.yuimenu li.selected a.selected, div.yuimenubar li.selected a.selected selector, which is located about halfway through the file. To change the roll-over color, simply change the background-colour property of the div.yuimenu li.selected, div.yuimenubar li.selected selector to whatever color you prefer.

    The last thing that you might want to do is change the image that denotes the menu item has a submenu. By default it is a right-facing angle bracket type thing. This is the most complex change that you'll need to make, but can still be done very easily. First of all, you'll need a couple of images, called arrow_nrm.gif and arrow_hov.gif (I'm trying to keep to a similar naming convention to Yahoo!), which should be saved to the assets folder. Next, open the menu.css file in your text editor and find the div.yuimenu li.hassubmenu em.submenuindicator, div.yuimenubar li.hassubmenu em.submenuindicator selector. You should change the height and width properties to match those of your image. Also change the background-image rule so that it points to your image instead of map.gif.

    Now, copy all of the rules, beginning with display up to background-repeat. Now scroll down until you find the div.yuimenu li.hassubmenu em.submenuindicator.selected selector. Remove the rule that it currently holds and paste in the code block you just copied, but this time change the background-image rule to arrow_hov.gif. Now save the file and open yuimenu.html in your browser. Your custom image should be visible.

    This is just one of the many ways that the versatile menu control can be used as a quick and easy way to add navigation menu functionality to your site. The menu will work and appear identical in most modern browsers (IE6, IE7, FireFox 1 and 2.0 for sure), so this saves you from the usually long and laborious task of refining and modifying your code to get it working across browser platforms. There is tons more information on the Yahoo! Developer site, so be sure to check it out when you've finished playing around with this example.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Hi, I hope this follow-up article is a good demonstration of how to bend the YUI to...
       · try viewing this on a safari browser, it wont work properlyany idea of how to fix...
       · which version of Safari are you using and which version of OSX?
       · If I wanted to create the menu without any HTML markup, how would I go about...
     

    JAVASCRIPT ARTICLES

    - Validating Digits and Dates with jQuery`s Va...
    - Validating Ranges, Emails, and URLs with jQu...
    - More Uses for the jQuery Tooltip Plug-in`s b...
    - Building Image-Based Tooltips with the jQuer...
    - Using the jQuery Tooltip Plug-in`s bodyHandl...
    - Using Rangelength, Min and Max with the Vali...
    - Using Minlength and Maxlength with the Valid...
    - Modifying Tooltip Coordinates with the jQuer...
    - Applying a Fade Out Effect with the jQuery T...
    - Tracking Mouse Movements with the jQuery Too...
    - Checking Online Forms with the Validator jQu...
    - Nested JavaScript Functions as Objects
    - The jQuery Tooltip Plug-in
    - Active Client Pages at the Server
    - ACP Tab Web Page







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT