Can I style only Root menu elements via CSS?
Menu example:
M1
M1.1
M1.2
M1.2.3
M2
M2.1

I like to have other styles for elements M1 and M2, but this elements don't have any classes or id that identify its as root elements.

Comments

cburschka’s picture

Category: support » feature
Status: Active » Needs review
StatusFileSize
new903 bytes

Due to the way this module uses recursion, adding the class to li elements would be very difficult to implement.

However, a $toplevel flag exists in the function that generates the ul element, so adding this class to the root list is trivial.

In CSS, this just means root elements can't be referenced with li.menu-root-element, but have to be referenced with ul.menu-root li, so it works just as well.

Patch attached.

cburschka’s picture

Version: 5.x-0.x-dev » 5.x-1.0
Assigned: lalex » cburschka
Status: Needs review » Reviewed & tested by the community

Rerolled for 5.x-1.x.

This change doesn't actively change any behavior (aside from providing a menu-root class for CSS files to work with), so barring code-style issues this is RTBC.

cburschka’s picture

StatusFileSize
new1.38 KB

Forgot the attachment

cburschka’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

Committed to DRUPAL-5. I'm making a patch for D6 now.

cburschka’s picture

Status: Patch (to be ported) » Reviewed & tested by the community
StatusFileSize
new1.04 KB

Here's the patch for D6.

Note that the CSS class of the menu ul touches on another issue recently fixed for D5, where dhtml_menu's JS caused a conflict. The solution involved adding a dhtml_menu class to the element.

This patch does not add said class. That will be done in the porting of, um... of whatever issue described this. (This is what #node references in the commit messages are for...)

cburschka’s picture

Status: Reviewed & tested by the community » Fixed

I've committed this a while ago, but evidently forgot to mark it fixed.

Anonymous’s picture

Status: Fixed » Closed (fixed)