ul#menu li a:visited {color:yellow; }不工作
这是list.php的独立file.i已经在我的网页包含这一点,并试图突出当前页用点击的:主动,但它不是working..help我在这
<div class= "main-menu" id= "main-menu">
<?php include 'includes/list.php';?>
</div>
ul#menu li a:visited {color:yellow; }不工作
这是list.php的独立file.i已经在我的网页包含这一点,并试图突出当前页用点击的:主动,但它不是working..help我在这
<div class= "main-menu" id= "main-menu">
<?php include 'includes/list.php';?>
</div>
a:active是您点击链接时的状态。 (http://www.w3schools.com/cssref/sel_active.asp)
a:如果您点击链接之前访问过的状态。 (http://www.w3schools.com/cssref/sel_visited.asp)
你可以(在这个例子中 “电流”)添加一个类来突出你的当前链接
<li><a href="first.php" class="current">first</a></li>
并与CSS:
.current {
color: yellow;
}
如果你可以使用jQuery,然后你可以使用这个解决方案:
js脚本应该在所有页面中都是常见的,例如first.php,second.php等。 以下是代码:
<html>
<head>
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<style>
.active{ color:yellow; }
</style>
<body >
<?php
echo '<ul id="menu">
<li><a href= "first.php">first</a></li>
<li><a href= "second.php">second</a></li>
<li><a href= "third.php">third</a></li>
</ul>';
?>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('ul#menu li a').click(function() {
$('ul#menu li a').removeClass('active');
$(this).addClass('active');
});
});
</script>
</body>
</html>
希望,这会帮助你。
,我发现你的问题 在L1标签,你应该检查锚标记,并检查first.php页面确实存在与否 它意味着:HREF =“../ first.php”那是你的解决方案
但你的代码是这样的意思first.php不存在这就是为什么在CSS工作不正常
我希望你明白我居然告诉你
不清楚,但first.php页面存在 – VRG
它不工作,我有26名单(更将在未来添加)并添加cla ss到所有链接是一个好方法? – VRG
您只能将该类添加到要突出显示的链接。你可以显示不工作的代码吗? – adistoe
.current { \t color:black;}