简体   繁体   English

如何在html / css / js / php中更改活动菜单项样式

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

heres how my html is 继承人我的html是怎样的

<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. 正如您所看到的,“关于我们”页面的内容被加载到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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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