Hi I have looked at a variety of resources including Stackoverflow on how to use an Nth child selector and Class together and so far I am still failing.
Essentially my menu has Main categories (class =cat) and sub categories (class=subcat)
I want Each of the Main categories to be coloured differently. sub categories all stay the same. it is likely there may be multiple subcats in between each main cat. So, example:
Beef
steak
roast
Chicken
Breast
drumsticks
wings
Fish
Salmon
I can make it work so long as I don't put the class in - the instant the class goes in the nth-child selector fails.
css:
#nav ul li.cat a {
display:block;
background-color: #265054;
font-size: 1em;
padding-left: 25px;
height: 18px;
padding-top: 2px;
margin: 1px 0px;
color: #FFFF00;
}
#nav ul li.cat a:nth-child(2) {
background-color: #728c8c;
}
Code:
<?php
if (count($navlist)){
echo "<ul>";
foreach ($navlist as $key => $list){
foreach ($list as $topkey => $toplist){
echo "<li class='cat'>";
echo anchor("welcome/cat/$topkey",$toplist['name']);
echo "</li>\n";
if (count($toplist['children'])){
foreach ($toplist['children'] as $subkey => $subname){
echo "\n<li id='subcat'>";
echo anchor("welcome/cat/$subkey",$subname);
echo "</li>";
}
}
}
}
echo "</ul>\n";
}
?>
Many Thanks for all your help !