我已经尝试了几种不同的方法来在我的导航中添加一个 current 类。
我在以下网址阅读了一篇关于这样做的文章: http: //alistapart.com/article/keepingcurrent
到目前为止,我没有运气将任何方式合并到我的网站中。
我觉得我错过了什么。
我使用名为 nav.php 的包含文件将导航拉入站点:
<div id="nav">
<div id="nav-container">
<ul id="nav-content" class="top menu">
<li<?php if ($thisPage=="home")
echo " id=\"currentpage\""; ?>>
<a href="/index2013.php">Home</a></li>
<li<?php if ($thisPage=="portfolio")
echo " id=\"currentpage\""; ?>>
<a href="/design/designsystems/unitedway/unitedway.php">Portfolio</a></li>
<li<?php if ($thisPage=="services")
echo " id=\"currentpage\""; ?>>
<a href="/services/services.php">Services</a></li>
<li<?php if ($thisPage=="resources")
echo " id=\"currentpage\""; ?>>
<a href="/resources/resources.php">Resources</a></li>
<li<?php if ($thisPage=="blog")
echo " id=\"currentpage\""; ?>>
<a href="http://kristinemorical.com/wordpress/kristine-blog/">Blog</a></li>
<li<?php if ($thisPage=="contact")
echo " id=\"currentpage\""; ?>>
<a href="/contactinfo/contact.php">Contact</a></li>
</ul>
</div>
</div>
这是我在索引页正文中的内容:
<?php $thisPage="home"; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Kristine Morical : Home</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="Kristine Morical" />
<?php include('http://www.kristinemorical.com/includes/head.php'); ?>
</head>
<body id="body">
<?php include('http://www.kristinemorical.com/includes/header.php'); ?>
<?php include('http://www.kristinemorical.com/includes/nav.php'); ?>
<div id="outer" class="clearfix">
<div id="sidebar-wrapper">
<?php //include('http://www.kristinemorical.com/includes/sidebar.php'); ?>
</div>
<div id="content" role="main">
</div> <!-- end #main -->
</div> <!-- end #outer -->
<?php include('http://www.kristinemorical.com/includes/footer.php'); ?>
</body>
</html>
我不确定我做错了什么。