# Build a menu (li.selected)

**URL:** <https://www.ruby-forum.com/t/build-a-menu-li-selected/110733>\
**Category:** Rails\
**Created:** [July 30, 2007, 1:20pm UTC](https://www.ruby-forum.com/t/build-a-menu-li-selected/110733 "2007-07-30T13:20:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmatos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pmatos](https://www.ruby-forum.com/u/pmatos)\
**Post date:** [July 30, 2007, 1:20pm UTC](https://www.ruby-forum.com/t/build-a-menu-li-selected/110733/1 "2007-07-30T13:20:36Z")

</div>

Hello,

when I try to create a menu I found the following limitation:  
the event li.selected does not work  
and, I am not being able to show an image when the menu option is  
selected

in my CSS exists the following code:  
.menu li.selected {  
…  
background: transparent url(/images/menu\_selected.gif) 100% 1px  
no-repeat;  
…  
}

in file: …\layouts\application.rhtml  
exists the following code:

- \<%= link\_to\_unless\_current "home", :controller =\> "home" %\>
- \<%= link\_to\_unless\_current "Resources", :controller =\> "resources", :action =\> "list" %\>

Anyone can tell me how can I do this?  
and tell me links source code samples of menus in rails?

thank You very much in advance

---

<div class="post-metadata">

**Author:** ![pmatos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pmatos](https://www.ruby-forum.com/u/pmatos)\
**Post date:** [July 30, 2007, 1:29pm UTC](https://www.ruby-forum.com/t/build-a-menu-li-selected/110733/2 "2007-07-30T13:29:30Z")

</div>

there is no such thing as an ‘event’ li.selected. all you have done  
there is define a class ‘selected’ for an li element within an  
element with the ‘menu’ class

you will need to add the class attribute to the li element yourself.

per your css/html example:

- ... 
 ...

---

<div class="post-metadata">

**Author:** ![pmatos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pmatos](https://www.ruby-forum.com/u/pmatos)\
**Post date:** [July 30, 2007, 1:37pm UTC](https://www.ruby-forum.com/t/build-a-menu-li-selected/110733/3 "2007-07-30T13:37:21Z")

</div>

Chris H. wrote:

> there is no such thing as an ‘event’ li.selected. all you have done  
> there is define a class ‘selected’ for an li element within an  
> element with the ‘menu’ class
> 
> you will need to add the class attribute to the li element yourself.
> 
> per your css/html example:
> 
> - ... 
> ...

sorry,

What I’m trying to do is:

when the menu option is “not selected” it has a background image  
and  
when the menu option is “selected”(chosen by the user) it has another  
background image

so, the class can not be fixed by “li”

Can You help me?  
thank You very much
