簡體   English   中英

如何在html / css / js / php中更改活動菜單項樣式

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

繼承人我的html是怎樣的

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

正如您所看到的,“關於我們”頁面的內容被加載到index.php中。 現在我想更改導航欄上不同風格的活動頁面鏈接。

請幫幫我 我希望這個問題很清楚。

根據選擇將類添加到特定項目;

<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