I need help making my links stay active and reflecting the css tag i assign to the a:active link to show users what page they are viewing.
I will paste in my css code and my nav bar set up. Any help with be appreciated. The way it is working now the hover link works but I can not seem to get the link to stay active when you are on the current page.
CSS
body {
width: 100%;
background-image: -webkit-linear-gradient(top, #a8a8a8, #f0f0f0);
color: #000000; /* text colour */
height: 900px; /* gradient uses the full height of the element */
padding: 3px; /* distance from border edge to text */
margin: auto; auto;
}
#navbar ul li {
float: left;
list-style-type: none;
margin: 0;
}
#navbar ul li a {
color: #ffffff;
background-color: #181818;
width: 180px;
display: block;
height: 50px;
line-height: 50px;
text-decoration: none;
text-align: center;
font-size: 24px;
Yes that is correct... And I don't know which part of my code is causing the problem, so I would assume someone who is willing to help would need all the information.
In my view there are few ways to go about this. If the links are contained in seperate pages it is easy to highlight them differently, the other option would be to write some javascript to recognise the page name and change CSS properties on the appropriate link.
CSS cannot detect this by itself.
The a:active selector refers to when the user clicks on a link - not something more dynamic. I am confident what you are trying to achieve can be done via jQuery.
Aside from that, improvements I would make is to correctly line and indent (I guess the indentation has been removed on this forum) your markup.
Haha. By giving an example wouldn't I just be doing it for you? check http://docs.jquery.com/Tutorials for tutorials using jQuery. It looks like you already have the relevant knowledge on the CSS side of things.
I just wanted to say thank you for giving me more credit then i deserve! I have learned everything I know over the past 4 or 5 months watching you tube videos and I have never posted a question on a forum before. I assume based on you guys thinking that I should already know this stuff that my code that I have posted must be decent...
I am going to try to go back and add that css example of links on each page and see how that works and the tutorial posted im going to check that out too.
I really appreciate the help if I had the knowledge of doing this or felt confident in my ability I would not of asked for help.
So thank you very much for those of you who helped me.
Bookmarks