Relative Position (in a DIV) - Horizontal Right

This sample demonstrates a right-aligned horizontal main menu with relative position inside a DIV container on the page.

The following settings are used for the main menu in the last section (i.e. MENU TREE FEATURES) of the configuration file (c_config.js):

// MAIN-MENU FEATURES
'horizontal', // ItemsArrangement ('vertical','horizontal')
'relative',   // Position ('relative','absolute','fixed')
'95px',       // X Position (values in CSS valid units- px,em,ex)
'0',          // Y Position (values in CSS valid units- px,em,ex)
true,         // RightToLeft display of the sub menus
false,        // BottomToTop display of the sub menus
...

Please just note that the menu items (the LI elements) of a horizontal main menu are floated. This means that if you have a horizontal relatively positioned main menu in a DIV (i.e. like the one in this example), you will have to clear the root UL element so that the main menu box takes its place correctly. For details please take a quick look at the following section of the SmartMenus 6 User's Manual ("manual.html" in the SmartMenus download package):

"6.1 For relatively positioned horizontal main menus clear the root UL element"

Because the menu items (the LI elements) of a horizontal main menu are left-floated a horizontal main menu cannot be automatically right-aligned. You can manually achieve right alignment for a horizontal main menu by setting a X Position value that will produce an appropriate left offset for the main menu and will shift it to the right - e.g. in this example:

'95px',       // X Position (values in CSS valid units- px,em,ex)

Notes

  1. The container DIV in this example has red background and 3px padding applied so that you could notice it easily. You could nest the menu tree in any DIV on your page.

Download this sample

You can download the complete example or just see the configuration file and the images used for it.

Configuration file


Shortcuts and Related

Bookmark / Share