Welcome Guest, Not a member yet? Register   Sign In
Setting a menu item to "selected"
#5

[eluser]Unknown[/eluser]
Hi there,

I was recently faced with a similar problem, and ended up using something similar to what Chris Coyier taught here.

In my view:
Code:
<body id="<?php echo $this->uri->segment(2); ?>">
    <nav id="mainNav">
        <ul>
            <li id="nav-myShelf">&lt;?php echo anchor('shelf/mine', 'My Shelf'); ?&gt;</li>
            <li id="nav-collection">&lt;?php echo anchor('shelf/collection', 'Library Collection'); ?&gt;</li>
            <li id="nav-addBook">&lt;?php echo anchor('shelf/addBook', 'Add book'); ?&gt;</li>
        </ul>
    </nav>
//...

In the CSS:
Code:
#mine #nav-myShelf a,
#collection #nav-collection a,
#addBook #nav-addBook a{
    background: #e3e3e3;
}

So what happens is: The body gets a dynamically generated id, and each menu item gets a unique id, too. With CSS, you then target the body id and the menu item id.

Hope this helps!

- Erik


Messages In This Thread
Setting a menu item to "selected" - by El Forum - 06-16-2010, 02:16 PM
Setting a menu item to "selected" - by El Forum - 06-16-2010, 02:38 PM
Setting a menu item to "selected" - by El Forum - 06-16-2010, 02:39 PM
Setting a menu item to "selected" - by El Forum - 06-16-2010, 08:56 PM
Setting a menu item to "selected" - by El Forum - 06-25-2010, 03:04 PM
Setting a menu item to "selected" - by El Forum - 08-14-2011, 05:52 PM
Setting a menu item to "selected" - by El Forum - 04-14-2012, 03:25 PM
Setting a menu item to "selected" - by El Forum - 04-14-2012, 05:01 PM
Setting a menu item to "selected" - by El Forum - 04-14-2012, 05:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB