Default CSS Horiz Menu with bg image on top level elements

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
mtjo
New Member
New Member
Posts: 3
Joined: Thu Oct 25, 2007 2:26 am

Default CSS Horiz Menu with bg image on top level elements

Post by mtjo »

I finally worked out the Horiz CSS Menu to work with background images in the top level elements for my companies site. IE6 caused the main probs. You'll just need to tweak the various style properties for your design.

Code: Select all

/** Horizontal menu for the CMS CSS Menu Module */
/** by Alexander Endresen */
/** Modified by MT Jordan */

/** Begin 'Navigation: CSSMenu - Horizontal' */

#menu
{
    clear: both;
    margin: 0 7px 0 7px;
}
#menuwrapper
{
    /** wrapper clears the floating elements of the menu */
    background: #255DDE url(path/to/menuwrapper bg image) center repeat-x;
    clear: both;
}
#primary-nav li li
{
    /** set the width of the menu elements at second level - leaving first level flexible. */
    width: 220px;
}

/** Set styles for multi level menu - DO NOT CHANGE */

#primary-nav, #primary-nav ul
{
    list-style: none;
    margin: 0px;
    padding: 0px;
}
#primary-nav ul
{
    position: absolute;
    top: auto;
    display: none;
    border: 1px solid #ccc; /** sets the border style for secondary+ levels */
}
#primary-nav ul ul
{
   left: 100%;
   top: 0;
}
#primary-nav li
{
   margin-left: 0px;
   float: left;
}
#primary-nav li li
{
   margin-left: 0px;
   margin-top: 0px;
   float: none;
   position: relative;
}

/** End set styles for two level menu - DO NOT CHANGE */

/** Styling the basic appearance of the menu elements */

#primary-nav a
{
    display: block;
    margin: 0px;
    padding: 6px 18px;
    text-decoration: none;
    font-size: 70%;
    font-weight: normal;
}
#primary-nav a:hover
{
    text-decoration: none;
}

/** Styling the appearance of top level menu items **********************************************************/

#primary-nav li, #primary-nav li.menuparent
{
    background: #255DDE url(path/to/top-level bg image) center repeat-x;
}
#primary-nav li.menuactive
{
    /** set background to #primary-nav li:hover properties to show active page being displayed **/
    /** set background to #primary-nav li properties to disable **/
    background: #255DDE url(path/to/top-level bg image) center repeat-x;
}
#primary-nav li:hover,
#primary-nav li.menuh,
#primary-nav li.menuparenth,
#primary-nav li.menuactiveh
{
    /** styling the appearance of top level menu items on hover */
    background: #3D88F7 url(path/to/top-level hover bg image) center repeat-x;
}
#primary-nav li a,
#primary-nav li a:hover
{
    border-right: 1px solid #B3CCFF;
    color: #fff;
}

/** Styling the appearance of secondary level menu items **************************************************/

/** Styling the basic appearance of the menuparents  */

#primary-nav ul li, #primary-nav ul li.menuparent
{
    background: #f7f7f7;
}
#primary-nav ul li.menuparent
{
    /** arrow for menuparents */
    background: #f7f7f7 url(images/cms/arrow.gif) center right no-repeat;
}
#primary-nav ul li:hover
{
    background: #CBE6FF;
}
#primary-nav ul li.menuparent:hover,
#primary-nav ul li.menuparenth,
#primary-nav ul li.menuactive
{
    /** arrow for menuparents on hover */
    background: #CBE6FF url(images/cms/arrow.gif) center right no-repeat;
}
#primary-nav ul li.menuh
{
    /** for secondary level menu items w/o children: < IE7 */
    background: #CBE6FF;
}
#primary-nav li li a,
#primary-nav li li a:hover
{
    padding: 4px 0px 4px 3px;
    color: #000;
    border: 0;
}

/** The magic - set to work for up to a 4 level menu, but can be increased unlimited */
/** Hat tip to http://solardreamstudios.com/learn/css/cssmenus for working out the proper order here */

/* add
#primary-nav li:hover ul ul ul ul ul
#primary-nav li.menuparenth ul ul ul ul ul
for fifth level
*/

#primary-nav li:hover ul ul,
#primary-nav li:hover ul ul ul,
#primary-nav li:hover ul ul ul ul,
#primary-nav li.menuparenth ul ul,
#primary-nav li.menuparenth ul ul ul,
#primary-nav li.menuparenth ul ul ul ul
{
    display: none;
}

/**
just add
#primary-nav ul ul ul ul li:hover ul
#primary-nav ul ul ul ul li.menuparenth ul
for fifth level
*/

#primary-nav li:hover ul,
#primary-nav ul li:hover ul,
#primary-nav ul ul li:hover ul,
#primary-nav ul ul ul li:hover ul,
#primary-nav li.menuparenth ul,
#primary-nav ul li.menuparenth ul,
#primary-nav ul ul li.menuparenth ul,
#primary-nav ul ul ul li.menuparenth ul
{
    display: block;
}

/** IE Hacks */

#primary-nav li li
{
    float: left;
    clear: both;
}
#primary-nav li li a
{
    height: 1%;
}
/** Opera Hacks */

.clearb
{
    clear: both;
}
#primary-nav ul
{
    width: 220px;
}

/** End of 'Navigation: CSSMenu - Horizontal' */


Post Reply

Return to “Tips and Tricks”