php - How to Make Menu Active
659
I have menu as follows
<ul>
<li><a href="index.php">Home</a></li>
</ul>
how to make it Active when I visit that Page. I tried as follows but no luck
#navigation a:active {
color: #000;
background: -webkit-gradient(linear, left top, left bottom, from(#DFE7FA), to(#FFF));
border-bottom-width:0px;
}
I'm new webie thanks for any suggestions
Answer
Solution:
Add id to your code as below
Update
Write Script as Below
Answer
Solution:
Each page has a class on the body tag that identifies it:
BODY OF HOME PAGE:
BODY OF ABOUT US PAGE:
Then you target those classes in your CSS, defining a different state for the current page:
CSS STYLE:
Answer
Solution:
In your
index.php
page, you need to edit the HTML this way:In other pages, say
about.php
, you might have something like this:And change the CSS to
.active
and not:active
, as the second one is a state of element:Answer
Solution:
The
:active
pseudo-selector is for when an element is well, active, for example while a link is being clicked.What you will need to do is give your
<a>
element a class attribute and style it accordingly.