我有四个 php 页面,homepage.inc.php、about.inc.php、contact.inc.php 和我的 index.php
<div id="menu">
<nav>
<a id="home" target="_self" href="index.php">Home</a>
<a id="about" target="_self" href="index.php?p=about">About us</a>
<a id="contact" target="_self" href="index.php?p=contact">Contact</a>
</nav>
</div>
<div id="content">
<?php
$pages_dir = 'pages';
if (!empty($_GET['p'])) {
$pages = scandir($pages_dir, 0);
unset($pages[0], $pages[1]);
$p=$_GET['p'];
if(in_array($p.'.inc.php', $pages)){
include($pages_dir.'/'.$p.'.inc.php');
}else {
echo 'Sorry, page not found.';
}
}else{
include($pages_dir.'/home.inc.php');
}
?>
</div>
这是我的 css active{background:gray;} 我想在我的菜单上添加一个活动类。如何?