Forum Moderators: not2easy

Message Too Old, No Replies

Highlight current /active page in Firefox

         

bunnysoap

4:51 pm on Dec 24, 2010 (gmt 0)

10+ Year Member



I did use a method by one of the posters on here but it was found via a search and two years old. I can get it to work in IE of all browsers but NOT in FF, Chrome or Safari. I will post all the relevant code.
CSS code

ul#nav
{
list-style: none;
font-family: Arial, Helvetica, sans-serif;
margin: 15px 0 0 0;
padding: 0;
}
#nav a:link, #nav a:visited {
display: block;
width: 180px;
height: 27px;
padding: 6px 3px 6px 1.5em;
color: #03C;
text-decoration: none;
font-size: 80%;
border-bottom: 1px solid #ebebeb;
}
#nav a:hover {
text-decoration: underline;
}
#binc a#inc,
#bici a#ici,
#bout a#out,
#bnh a#nh,
#bch a#ch,
#bph a#ph,
{
color:#f00;
font-weight: normal;
font-style: italic;
}

HTML Code:
<body id="binc">

(this is an include)
<li><a href="it_infrastructure.php" id="inc">INTERNAL NETWORK CONNECTIVITY</a></li>
<li><a href="internet_connectivity.php" id="ici">INTERNET CONNECTIVITY - INSIDE THE OFFICE</a></li>
<li><a href="internet_connectivity_outside.php" id="out">INTERNET CONNECTIVITY - OUTSIDE THE OFFICE </a></li>
<li><a href="network_hardware.php" id="nh">NETWORK HARDWARE</a></li>
<li><a href="computer_hardware.php" id="ch">COMPUTER HARDWARE</a></li>
<li><a href="peripheral_hardware.php" id="ph">PERIPHERAL HARDWARE</a></li>

I know that each body tag must correspond to the id tag in the link. Could it be that having the navigation as an include messes this whole thing up in 3 out of the 4 browsers I tested it in? Any help is very much appreciated. Happy Holidays to everyone!;)

alt131

4:42 pm on Dec 28, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi bunnysoap, and welcome to WebmasterWorld !

The includes should not be a problem, but at first glance at your code (which may have been simplified for posting), there is no <ul> </ul> surrounding the list items.

That means
#nav a:link {...}
will not be applied because there is no
<ul id="nav"> in the html.

Second, you are being very specific with your selectors, but the styles being applied are the same. Rather than this:
#binc a#inc,
#bici a#ici,
#bout a#out ...

Consider:
#binc #nav a {...}
That will select the <a>'s in <ul id="nav">, on a page with <body id="binc"> - without having to specify all the id's (Less code = less room for error ;)

SuzyUK

10:49 am on Dec 29, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi bunnysoap and Welcome to WebmasterWorld!

I too am presuming that <ul id="nav"> is just missing from your sample and not your actual page (otherwise it wouldn't work in IE either

@alt131, the reason the selectors are so specific is that the idea is NOT to target all the <a>'s on the page. This code targets only link on the "active" page, giving a visual clue as to where you are - it's the CSS equivalent of scripting an "active" class onto navbar links.

@bunnysoap it's an easy one, a parse error - validating the CSS [jigsaw.w3.org] (always a good first stop, except we wouldn't have met you then ;)) would have spotted it for you

#binc a#inc,
#bici a#ici,
#bout a#out,
#bnh a#nh,
#bch a#ch,
#bph a#ph,
{
color:#f00;
font-weight: normal;
font-style: italic;
}


it's the comma after
#bph a#ph,
- there shouldn't be a comma after the last selector in a list

hth

alt131

9:23 pm on Dec 29, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh my goodness ...
@bunnysoap
Please ignore my post - it's badly wrong. What a dreadful welcome to WebmasterWorld - but don't be put off - as suzy's post shows, there's always useful help available.

@suzy.
I'd say good catch, I think this counts as search and rescue ;) Excellent spotting that pesky comma!