[SOLVED] image menu with different first and last menu image

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
elkman
Power Poster
Power Poster
Posts: 262
Joined: Thu Jan 11, 2007 9:16 pm

[SOLVED] image menu with different first and last menu image

Post by elkman »

I am trying to convert a css image menu where the first and last menu item use a different hover image then the center menu items. I know I read somewhere in the forums how to do this but I can't seem to find it in the new forum.

Can anyone tell me how to do this or hopefully steer me to the correct forum topic? I believe the forum answer came from Dr. CSS.

Here is a link to the menu I am trying to convert to use CMS Menu manager. http://www.tellerlinks.com/mountainarts/

Thanks for any help.

Elkman
Last edited by elkman on Wed Mar 09, 2011 12:47 pm, edited 1 time in total.
uniqu3

Re: image menu with different first and last menu image

Post by uniqu3 »

With smarty you can do it like this, open MenuManager Template you are using and add as you can see below name='menuitem' or whatever it you want and can remeber.
Then where link for that menu is built you add the code as shown below.

This will only apply if there is no Subnavigation displayed in that menu, so if your last item would have subnavigation dropdown, .last-menu-item would be applied to last menu element.

Code: Select all

{foreach from=$nodelist item=node name='menuitem'} <!-- your MenuManager code --> <a href="{$node->url}"{if $smarty.foreach.menuitem.first} class="first-menu-item"{/if}{if $smarty.foreach.menuitem.last} class="last-menu-item"{/if}>{$node->menutext}</a> {/foreach} 
Another way would be :first-child and :last-child pseudo class in css, and js (for example jquery http://api.jquery.com/last-child-selector/) fallback for browser like IE that do not support it.
elkman
Power Poster
Power Poster
Posts: 262
Joined: Thu Jan 11, 2007 9:16 pm

Re: image menu with different first and last menu image

Post by elkman »

Thank you. Works perfectly!

Elkman
Post Reply

Return to “Layout and Design (CSS & HTML)”