DotDragnet
February 04, 2012, 11:02:18 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Mobile users - Our forum is Tapatalk enabled. http://www.tapatalk.com/
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: what's wrong with this code  (Read 665 times)
charlie
Hero Member
*****
Posts: 822



View Profile WWW Awards
« on: August 05, 2010, 10:55:52 AM »

sorry .. kind of same as previous post but thought more likely to be seen here

basically .. want the link clicked to change and stay a colour while active.

Thought this would do it but doesn't

Quote
<strong><a id="active" href="patientinfo.php">PATIENT INFORMATION</a></strong>


and CSS as follows

Quote
#active {color:#0aff04;}

doesn't work though ... any ideas?

ta
Logged

Mr Anderson
DDN Contribs
Hero Member
*****
Posts: 2209



ap4a.uk ap4a
View Profile WWW Awards
« Reply #1 on: August 05, 2010, 11:07:10 AM »

a#active:active { }

Bearing in mind that an active state is the link state while it is being clicked.

Do you want it to be a set colour while on that page? If so, give that page's body tag an ID as well, and target the combo.
Logged

charlie
Hero Member
*****
Posts: 822



View Profile WWW Awards
« Reply #2 on: August 05, 2010, 11:17:44 AM »

mmm not sure I understand (hungover!)

But yes ... I have an 'include' menu for the patient info section (which has subsections). Once they click the 'treatment' section, a different 'include' menu will be included and whilst on those, I would like the colour to stay the same.
Logged

Mr Anderson
DDN Contribs
Hero Member
*****
Posts: 2209



ap4a.uk ap4a
View Profile WWW Awards
« Reply #3 on: August 05, 2010, 11:43:14 AM »

Give the body tag on each page an ID. Give each menu item an ID, eg: <body id="homepage"> and <li id="homelink"><a href="/" >Home</a></li>. Then style:

#homepage #homelink a { color: #0aff04; }

If you find that different link states are still changing then you have other CSS that needs to be overridden, eg:

#homepage #homelink a:link,
#homepage #homelink a:visited,
#homepage #homelink a:focus,
#homepage #homelink a:hover,
#homepage #homelink a:active { color: #0aff04; }
Logged

charlie
Hero Member
*****
Posts: 822



View Profile WWW Awards
« Reply #4 on: August 05, 2010, 12:05:11 PM »

Thanks ... have to pop out now .. will have a look in the morning ..

cheers smile
Logged

charlie
Hero Member
*****
Posts: 822



View Profile WWW Awards
« Reply #5 on: August 06, 2010, 01:08:48 PM »

mmmm am I doing something wrong .. nothing happening

I have

Quote
<body id="patientinfo">

then in the menu code

Quote
<strong><a id="patientinfolink" href="patientinfo.php">PATIENT INFORMATION</a></strong>

and the css


Quote
#patientinfo #patientinfolink a:link,
#patientinfo #patientinfolink a:visited,
#patientinfo #patientinfolink a:focus,
#patientinfo #patientinfolink a:hover,
#patientinfo #patientinfolink a:active { color: #000000; }

Logged

Mr Anderson
DDN Contribs
Hero Member
*****
Posts: 2209



ap4a.uk ap4a
View Profile WWW Awards
« Reply #6 on: August 06, 2010, 01:48:53 PM »

mmmm am I doing something wrong .. nothing happening

Your ID is on the anchor tag, but you're targeting your CSS at an anchor that is the child of the ID containing element.
Logged

charlie
Hero Member
*****
Posts: 822



View Profile WWW Awards
« Reply #7 on: August 06, 2010, 03:44:20 PM »

 Huh? ... not seeing what I'm doing differemtly to waht you suggested .... or maybe I'm missing something (like a few grey cells!)
Logged

Mr Anderson
DDN Contribs
Hero Member
*****
Posts: 2209



ap4a.uk ap4a
View Profile WWW Awards
« Reply #8 on: August 06, 2010, 03:57:47 PM »

Huh? ... not seeing what I'm doing differemtly to waht you suggested .... or maybe I'm missing something (like a few grey cells!)

In my example the ID is on the list item, on yours it's on the anchor. So instead of:

Code:
#patientinfo #patientinfolink a:link,
#patientinfo #patientinfolink a:visited,
#patientinfo #patientinfolink a:focus,
#patientinfo #patientinfolink a:hover,
#patientinfo #patientinfolink a:active { color: #000000; }

You need:

Code:
#patientinfo a#patientinfolink:link,
#patientinfo a#patientinfolink:visited,
#patientinfo a#patientinfolink:focus,
#patientinfo a#patientinfolink:hover,
#patientinfo a#patientinfolink:active { color: #000000; }
Logged

charlie
Hero Member
*****
Posts: 822



View Profile WWW Awards
« Reply #9 on: August 06, 2010, 04:32:46 PM »

Thanks for that .... need to get my head around 'why' but that's for another day ... it works a treat anyway so thank you for that ... client will be hoppy (I Hope !!) :-)


cheers again
Logged

sarahA
DDN Contribs
Hero Member
*****
Posts: 2122



View Profile WWW Awards
« Reply #10 on: August 06, 2010, 04:44:16 PM »

Because #patientinfolink is the id of the a attribute. You know if you have <p id="blah"> you'd use p#blah if you wanted to target specifically a paragraph with an ID of blah

Anyway, so <a id='patientinfolink' ..> needs to be targeted as a#patientinfolink

you read the selector from left to right so #patientinfolink a assumes that the anchor tag is contained within something that has an ID of patientinfolink.


What Mr A was trying to explain was instead of adding the ID to your anchor tag, add it to the list item. So if your nav is

Code:
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Page 1</a></li>
etc.
</ul>

Then you put the ID on the list item, and the id on the body tag, then you target it as per the example he gave.

- or have I just confused things even more? unsure
Logged

charlie
Hero Member
*****
Posts: 822



View Profile WWW Awards
« Reply #11 on: August 06, 2010, 05:29:36 PM »

Lol .. I am a dumbass .... going to print this off and read it properly later when the more logical part of my brain is functioning :-)


ta
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2006-2008, Simple Machines Valid XHTML 1.0! Valid CSS!