所以,我正在写一个菜单,我希望它在该页面上保持某种颜色。我已经在页面上添加了“class = 'active'”,并尝试将它添加到 CSS,但它不起作用。有任何想法吗?
PHP代码:
<?php
$currentPage = basename($_SERVER['REQUEST_URI']);
print "<div id = 'submenu-container'>";
print "<div id = 'submenu'>";
print "<ul class = 'about'>";
print " <li><a href='about.php#about_intro.php'if($currentPage=='about.php#about_intro.php' || $currentPage=='about.php') echo 'class='active''>About</a></li>";
print " <li><a href='about.php#about_team.php'if($currentPage=='about.php#about_team.php') echo 'class='active''>Team</a></li>";
print " <li><a href='about.php#about_services.php' if($currentPage=='about.php#about_services.php') echo 'class='active'>Services</a></li>";
print " </ul>";
print "</div>";
print"</div>";
?>
CSS:
#submenu ul li a .active {
background:#FFF;
}