当我们从一页移动到另一页时,如何更改CSS中相应的导航链接

问题描述 投票:-1回答:1

一种方法是将活动属性添加到我们所在页面的导航链接中:

 <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中还有其他替代方法吗?

javascript html css dom bootstrap-4
1个回答
0
投票
<style>
a:active
{
  color:red;
  /*any style here! */
}
</style>

希望!你得到了答案😊

© www.soinside.com 2019 - 2024. All rights reserved.