473,396 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

css and active link

mickey0
142 100+
Hello,
I did throuhg CSS a navigation menu. It seems fine; as you can see I set the 'current' page as 'active'. When I click on a link (button) the background changes colour. The problem is the the background of the 'activeLink' remains 'active'; How can I avoid this last? Can I do it by means of CSS or maybe do I need JS to accomplish this?
Thanks in advance
Expand|Select|Wrap|Line Numbers
  1. div#menu a:link, div#menu a:visited {     
  2.     background-color: #485e49;
  3.     color: #a2b3a1;
  4. }
  5. div#menu a:hover, div#menu a:focus, div#menu a:active {
  6.    color: White; 
  7.    text-decoration: none; 
  8.    background-color: #a2b3a1;   
  9. }
  10. div#menu a#activelink {
  11.      color: White; 
  12.      background-color: #a2b3a1; 
  13.      text-decoration: none 
  14. }
  15.  
  16.     <div id="menu">     
  17.             <a id="activelink" href="#">HOME</a>
  18.             <a href="#">CUSTOMERS</a>
  19.             <a href="#">NEWS</a>
  20.             <a href="#">ABOUT</a>
  21.     </div>    
  22.  
Oct 26 '11 #1
4 3491
drhowarddrfine
7,435 Expert 4TB
Without trying this, you may want to set #menu a:visited to the background color you want but remove that from the first line of your css.
Oct 26 '11 #2
mickey0
142 100+
not sure of having understood what you mean; the point is that:
Expand|Select|Wrap|Line Numbers
  1. <a id="activelink" href="#">HOME</a>
  2.  
remains always active, even when I select another button (another <a>). How can I deselect it when I select another <a>?
hope clearer now.....
Oct 26 '11 #3
drhowarddrfine
7,435 Expert 4TB
I may be confused with when you mean "active" and when you mean "visited". Active means when the user is clicking on the link. It may be "visited" that you want to be working with.

I just don't have time to look at it. Yes, it's possible javascript might be what you need.
Oct 26 '11 #4
Garry
4
Your CSS needs
background-color: blue
OnMouseOver background-color: yellow
(The bit I think you have missed is)
OnMouseOut background-color: blue

You need to set the color back to your original color on mouse out.
Oct 26 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

36
by: Peter Brause | last post by:
Hello, my stylesheet shows different colors for visited, active and hovered links. It works fine in IE 6, but in Opera 7 the color for the active link (red background) is never shown. How to...
6
by: Carla | last post by:
hi people, I have a little problem that I can't solve with css and i was wondering if you could help me. I have 4 links, I want that when I click/mouseover in the link 1, it turns to a color...
4
by: crhaynes | last post by:
I'm having trouble with my CSS. My links are black, my hover is orange and my active link is red. When I select a link it turns red but i does not retain that color when the selected page loads. ...
2
by: paulmac106 | last post by:
Hi, I have a menu control that has two Menu choices One is "View History Items" the second is "PDA" My problem is as you roll the mouse over the menu options, the second one works only...
1
beacon
by: beacon | last post by:
I'm looking to reset the visited link color once another link is selected. Also, once that link takes me to a particular page, I want the font-weight for that page to be bold to indicate that it's...
2
by: Garima12 | last post by:
There is htm page. In its body I am calling a class from stylesheet called TaskbarStyle(classname). Now I want to change the color of hyperlink in this page as well as their active link color. I am...
1
by: Sarah Hammond | last post by:
Hello There, I am using jquery Spry Sliding panels for a new site i am working on. I am looking to style similarly to this example in particular I am trying to find a way to give the navigation...
1
Fary4u
by: Fary4u | last post by:
using asp while condition how can i write perticular link as a selected value ? <a class="mainlevel" href="p.asp?strCat=<%= strcat%>"> <%= strcat %></a> using CSS style sheet
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.