htmlhtml-listssifr

sifr - How to make it work with .active ul links


I have a SIFR script which coverts primary navigation items thusly:

[code]
/*********************
* sIFR configuration
**********************/

var itc = {
    src: '/assets/js/sifr3/demo/font2.swf'
    ,ratios: [7, 1.32, 11, 1.31, 13, 1.24, 14, 1.25, 19, 1.23, 27, 1.2, 34, 1.19, 42, 1.18, 47, 1.17, 48, 1.18, 69, 1.17, 74, 1.16, 75, 1.17, 1.16]
}

sIFR.activate(itc);
sIFR.useStyleCheck = false;
sIFR.replace(itc, {
    selector: 'h2, #primary_nav ul li'
    ,css:[
        '.sIFR-root { font-size:14px;font-weight:normal; }',
        ,'#primary_nav ul li a { color:#000000; text-decoration: none; }'
        ,'#primary_nav ul li a:hover { color: #000000;  text-decoration:underline; background-color:#000000; }'
        ,'#primary_nav ul li.active a { color:#000000;  text-decoration:underline;}'
    ]
    ,wmode: 'transparent'
    ,fitExactly:true
    ,forceClear:true
    ,forceSingleLine:true
}); 
[/code]

However, the "li.active a" gets applied to every menu item. This isn't what I want.

I want it to just apply the .active class to those who have that class.

The "#primary_nav ul li.active a" is used on the menu list item you are on.

ie:

[code]
<li class="active"><a href="#">Home</a></li>
<li><a href="#">News</a></li>
<li><a href="#">Some other menu item</a></li>
[/code]

How do I get SIFR to only apply .active to the list active item?

Thanks.


Solution

  • First execute a replacement for #primary_nav ul li.active which has the special styling, and then replace all other list items.

    Also, in the CSS rules for the replacement you can't repeat #primary_nav ul li, just use a instead.