【问题标题】:Bootstrap dropdown on toggle change background colorBootstrap 下拉菜单切换背景颜色
【发布时间】:2023-02-14 22:56:43
【问题描述】:

我有这段代码:

      <div class="dropdown">
        <button class="btn btn-secondary dropdown-toggle buttonForProfile" type="button" id="dropdownMenuButton" data-bs-toggle='dropdown' aria-haspopup="true" aria-expanded="false">
          <?php echo $_SESSION['username']; ?>
        </button>
        <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
          <a class="dropdown-item" href="#">Profile</a>
          <a class="dropdown-item" href="#">Subscriptions</a>
          <a class="dropdown-item" href="./php/signout.php">Sign out</a>
        </div>
      </div>

我添加了一些 css,现在它看起来像这样:

当我点击它时,背景变回默认:

切换下拉菜单时如何更改灰色背景?

【问题讨论】:

    标签: html jquery css bootstrap-5


    【解决方案1】:
     #dropdownMenuButton:focus {
       background-color: //color;
     }
    

    PS:btn-secondary 给它的颜色是灰色,如果你自定义颜色,你不需要它。

    【讨论】:

      猜你喜欢
      • 2014-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-07
      • 2022-08-05
      • 2023-01-05
      • 1970-01-01
      • 2013-11-04
      相关资源
      最近更新 更多