[英]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.