单击下拉菜单(Bootstrap 4)时切换箭头

时间:2019-01-10 21:17:42

标签: twitter-bootstrap bootstrap-4

Bootstrap 4具有默认的插入标记,单击下拉菜单时,我想将插入标记更改为向上箭头。

<div class="dropdown">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria- expanded="false">Dropdown</button>
  <div class="dropdown-menu" aria-labelledby="dropdownMenu2">
    <button class="dropdown-item" type="button">Action</button> <button class="dropdown-item" type="button">Another action</button>
    <button class="dropdown-item" type="button">Something else here</button>
  </div>
</div>

Demo

1 个答案:

答案 0 :(得分:1)

您可以定位::after伪元素,并在显示下拉菜单时将其旋转180度:

  .dropdown.show button::after {
    transform:rotate(180deg);
  }

Demo