Search code examples
angulartwitter-bootstrapngx-bootstrap

How to make dropdown on top of accordion


I am using ngx-accordion module to show like this enter image description here

Now when I click on details dropdown button the view is enter image description here

The accordion adjusts its height to the dropdown. But I want the dropdown to be on top of accordion and not inside.


Solution

  • I'm not using ngx-bootstrap but in some similar libraries you can use an appendToBody option to solve such errors.

    For ngx-bootstrap you can find an example here:

    <div class="btn-group" dropdown container="body">
      <button id="button-container" dropdownToggle type="button" class="btn btn-primary dropdown-toggle"
              aria-controls="dropdown-container">
        Dropdown on Body <span class="caret"></span>
      </button>
      <ul id="dropdown-container" *dropdownMenu class="dropdown-menu"
          role="menu" aria-labelledby="button-container">
        <li role="menuitem"><a class="dropdown-item" href="#">Action</a></li>
        <li role="menuitem"><a class="dropdown-item" href="#">Another action</a></li>
        <li role="menuitem"><a class="dropdown-item" href="#">Something else here</a></li>
        <li class="divider dropdown-divider"></li>
        <li role="menuitem"><a class="dropdown-item" href="#">Separated link</a>
        </li>
      </ul>
    </div>
    

    Key part is to add container="body" to your dropdown.