CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 17th, 2013, 03:31 PM
puskas97 puskas97 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 6 puskas97 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 15 sec
Reputation Power: 0
Question CSS Problem: Change the link color of active page in Navigation

I'm sure this is has been posted with solutions, but I'm very new to CSS so am looking for specific help related to the CSS sheet I am actually using.

As a new user I can not post the URL of my page or css sheet.

My problem:

I want the navigation bar to indicate the active page by changing color.

I have managed to make the color change on a mouse hover over:

#nav a:hover {
background: #FA0;
text-decoration: none;
color: #FFFFFF;
}

However, I do not know how to make it stay a different color to show which is the active page.

Can you suggest anything?

Many thanks.

Reply With Quote
  #2  
Old March 23rd, 2013, 01:39 AM
radenli radenli is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 4 radenli User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 20 sec
Reputation Power: 0
Try this

a:active
{
background-color:#FFFFFF; /*color of your choice*/
}
Comments on this post
DonR agrees!

Reply With Quote
  #3  
Old March 23rd, 2013, 02:51 PM
puskas97 puskas97 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 6 puskas97 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 15 sec
Reputation Power: 0
Still not working

Hello Radenli,

Thanks for helping.

I placed the code you suggested below the code to change the color when using mouse hover. But it still didn't maintain a change in background color when on that particular active page.

Am I doing something wrong?

#nav a:hover {
background: #FA0;
text-decoration: none;
color: #FFFFFF;
font-size: 16pt;
}

#nav a:active
{
background-color:#FFFFFF; /*color of your choice*/
}

#nav a {
text-decoration: none;
text-transform: lowercase;
color: #FA0;
font-family: Arial, Helvetica, sans-serif;
font-size: 16pt;
}

Reply With Quote
  #4  
Old March 23rd, 2013, 06:02 PM
radenli radenli is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 4 radenli User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 20 sec
Reputation Power: 0
You need to replace the color

you need to replace the color code #FFFFFF; to other color you like.
you are using "#FFFFFF"(white) on both :hover and :active, you will not see the color change.

Reply With Quote
  #5  
Old March 23rd, 2013, 08:08 PM
DonR DonR is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 460 DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)  Folding Points: 29722 Folding Title: Starter FolderFolding Points: 29722 Folding Title: Starter Folder
Time spent in forums: 2 Weeks 1 Day 21 h 57 m 10 sec
Reputation Power: 216
Do you have separate static HTML pages?
If so, you will need to create a class of lets say "active" and give it a color of your choice. And in the navigation link of that ACTIVE page, add the attribute class="active".

Reply With Quote
  #6  
Old March 24th, 2013, 10:00 AM
puskas97 puskas97 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 6 puskas97 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 15 sec
Reputation Power: 0
The color white would still work.

Quote:
Originally Posted by radenli
you need to replace the color code #FFFFFF; to other color you like.
you are using "#FFFFFF"(white) on both :hover and :active, you will not see the color change.


Hello Radenli,

If I keep the color white "#FFFFFF", it would still work and show the user which page they were currently on, as the background to the navigation bar is actually dark blue.

So this is not the solution.

Thanks

(I'm going to try the proposed solution below).

Reply With Quote
  #7  
Old March 24th, 2013, 10:02 AM
puskas97 puskas97 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 6 puskas97 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 15 sec
Reputation Power: 0
A new class "active"

Quote:
Originally Posted by DonR
Do you have separate static HTML pages?
If so, you will need to create a class of lets say "active" and give it a color of your choice. And in the navigation link of that ACTIVE page, add the attribute class="active".


Hello Don,

I have created the new class, called it active and changed the colors to match what I want. However, how do I actually do the last part of your suggestion?

(And in the navigation link of that ACTIVE page, add the attribute class="active".)

Thanks

Reply With Quote
  #8  
Old March 24th, 2013, 12:01 PM
DonR DonR is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 460 DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)  Folding Points: 29722 Folding Title: Starter FolderFolding Points: 29722 Folding Title: Starter Folder
Time spent in forums: 2 Weeks 1 Day 21 h 57 m 10 sec
Reputation Power: 216
I need to know if all of your pages are separate HTML pages.

And it would really help if we could see a link to your code or see your html code and a tree-view of all of your files [at least filenames as this would answer my above question].

At least post your navigation code, please.

Reply With Quote
  #9  
Old March 24th, 2013, 01:53 PM
puskas97 puskas97 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 6 puskas97 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 15 sec
Reputation Power: 0
Post Tree View of Files, HTML and CSS

...........................................................
I will try to post what I believe will help.

HTML Page with information about what is in the navigation bar: (I dont know why the new active class I made appears 3 times)

...........................................................


<body>
<span class="active"><span class="active"><span class="active">
</span></span></span>

<div class="active" id="bg">
<div id="outer">
<div id="header">
<div id="nav">

<ul>
<li class="first">
<a href="index.htm" accesskey="H" title="Link to Home page."><b>H</b>ome</a></li>
<li><a href="tools.htm" accesskey="T" title="Link to Teacher Tools page."><b>T</b>eacher Tools</a></li>
<li><a href="contact.htm" accesskey="C" title="Link to contact page."><b>C</b>ontact</a></li>
</ul>

<br class="clear" />
</div>
<img src="images/banner3.gif" width="981" height="69" alt="Web 2.0 Tools Logo" />
</div>
<div id="main">
<div id="content">
<div id="box1">

...........................................................
And the CSS code for the navigation:
...........................................................


#nav {
position: absolute;
bottom: 0;
left: 0;
height: 57px;
line-height: 57px;
padding: 0 24px 0 24px;
width: 932px;
margin: 0 0 0 0;
background: #08286e;
}

#nav a:hover {
background: #FA0;
text-decoration: none;
color: #FFFFFF;
font-size: 16pt;
}

#nav a:active
{
background-color:#FFFFFF; /*color of your choice*/
}

#nav a {
text-decoration: none;
text-transform: lowercase;
color: #FA0;
font-family: Arial, Helvetica, sans-serif;
font-size: 16pt;
}

#nav li {
margin: 0 1em 0 0;
padding: 0 1em 0 1em;
}


#nav li.active {
background: #fff;
}

#nav li.active a {
color: #34564F;
}

#nav ul {
list-style: none;
}

#nav ul li {
float: left;
font-family: Arial, Helvetica, sans-serif;
}

...................................................
Summarised Tree View of Files

...................................................

Site Name: Teacher Tools

HTML Pages:
- index.htm
- tools.htm
- contact.htm
- style.css

Reply With Quote
  #10  
Old March 24th, 2013, 03:51 PM
DonR DonR is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 460 DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)  Folding Points: 29722 Folding Title: Starter FolderFolding Points: 29722 Folding Title: Starter Folder
Time spent in forums: 2 Weeks 1 Day 21 h 57 m 10 sec
Reputation Power: 216
ok, this is what we want to focus on.
Code:
<ul>
<li class="first">
<a href="index.htm" accesskey="H" title="Link to Home page."><b>H</b>ome</a></li>
<li><a href="tools.htm" accesskey="T" title="Link to Teacher Tools page."><b>T</b>eacher Tools</a></li>
<li><a href="contact.htm" accesskey="C" title="Link to contact page."><b>C</b>ontact</a></li>
</ul>

#nav li.active a {
color: #34564F;
}


you can get rid of this
Code:
<span class="active"><span class="active"><span class="active">
</span></span></span>

<div class="active" id="bg">
(unless you need the <div id="bg"> but get rid of that class="active" in that DIV.)
--------------------------------------------------------------

what you will want to do in each of your html files is to add the class="active" to the <li> item that corresponds to that ACTIVE page.

For example, in your "index.htm" page you will want this
Code:
<ul>
<li class="first active">
<a href="index.htm" accesskey="H" title="Link to Home page."><b>H</b>ome</a></li>
<li><a href="tools.htm" accesskey="T" title="Link to Teacher Tools page."><b>T</b>eacher Tools</a></li>
<li><a href="contact.htm" accesskey="C" title="Link to contact page."><b>C</b>ontact</a></li>
</ul>


in your tools.htm file you want this
Code:
<ul>
<li class="first">
<a href="index.htm" accesskey="H" title="Link to Home page."><b>H</b>ome</a></li>
<li class="active"><a href="tools.htm" accesskey="T" title="Link to Teacher Tools page."><b>T</b>eacher Tools</a></li>
<li><a href="contact.htm" accesskey="C" title="Link to contact page."><b>C</b>ontact</a></li>
</ul>


and in your contact.htm, you want this
Code:
<ul>
<li class="first">
<a href="index.htm" accesskey="H" title="Link to Home page."><b>H</b>ome</a></li>
<li><a href="tools.htm" accesskey="T" title="Link to Teacher Tools page."><b>T</b>eacher Tools</a></li>
<li class="active"><a href="contact.htm" accesskey="C" title="Link to contact page."><b>C</b>ontact</a></li>
</ul>

then, just set the color to what you want in this
Code:
#nav li.active a { color: #34564F; }

Reply With Quote
  #11  
Old March 24th, 2013, 04:44 PM
puskas97 puskas97 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 6 puskas97 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 15 sec
Reputation Power: 0
Legend

DonR = Legend

Thank you so much. It works!


Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > CSS Problem: Change the link color of active page in Navigation

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap