简体   繁体   中英

How to change active menu item style in html/css/js/php

heres how my html is

<ul class="navigation">
<li><a href="index.php">Home</a></li>
<li><a href="index.php?content=about">About us</a></li>
</ul>

as you can see the content of "about us" page is loaded in to index.php. now i want to change active page link on nav bar different style.

please do help me. i hope this question is clear.

to add a class to a particular item based on selection;

<ul class="navigation"> 
<li <?php if(!isset($_GET['content'])) { echo 'class="active"'; } ?>><a href="index.php">Home</a></li> 
<li <?php if(isset($_GET['content']) && $_GET['content']=='about') { echo 'class="active"'; } ?>><a href="index.php?content=about">About us</a></li> 
</ul>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM