一种方法是将活动属性添加到我们所在页面的导航链接中:
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link navLink active" href="userhome.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link navLink" href="pool.php">Pool</a>
</li>
<li class="nav-item">
<a class="nav-link navLink" href="tickets.php">Tickets</a>
</li>
<li class="nav-item">
<a class="nav-link navLink" href="#">Winners</a>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link navLink " href="userhome.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link navLink active" href="pool.php">Pool</a>
</li>
<li class="nav-item">
<a class="nav-link navLink" href="tickets.php">Tickets</a>
</li>
<li class="nav-item">
<a class="nav-link navLink" href="#">Winners</a>
</li>
</ul>
...依此类推
JavaScript或CSS中还有其他替代方法吗?
<style>
a:active
{
color:red;
/*any style here! */
}
</style>
希望!你得到了答案😊