1

My current dropdown list is large. See the image below.

Image

How to fix this issue? I'm thinking of using proper JS to reposition the menu. Please help. How can I disable auto-positioning?

Here's an example of my code

<div class="btn-group">
                <button type="button" class="btn btn-danger dropdown-toggle"  data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    Action
                </button>
                <div class="dropdown-menu">
                    <a class="dropdown-item" href="#">Action</a>
                    <a class="dropdown-item" href="#">Another action</a>
                    <a class="dropdown-item" href="#">Something else here</a><a class="dropdown-item" href="#">Something else here</a><a class="dropdown-item" href="#">Something else here</a><a class="dropdown-item" href="#">Something else here</a><a class="dropdown-item" href="#">Something else here</a><a class="dropdown-item" href="#">Something else here</a><a class="dropdown-item" href="#">Something else here</a><a class="dropdown-item" href="#">Something else here</a><a class="dropdown-item" href="#">Something else here</a><a class="dropdown-item" href="#">Something else here</a>
                    <div class="dropdown-divider"></div>
                    <a class="dropdown-item" href="#">Separated link</a>
                </div>
            </div>

NOTE : When I scroll the page, an inline css applies on dropdown menu, and change css property as screen scroll. How can I fix this issue?

element.style {
    left: 0px;
    position: absolute;
    transform: translate3d(16px, -258px, 0px);
    top: 0px;
    will-change: transform;
}

Thanks in advance

Ibrahim Tareq
  • 336
  • 2
  • 12
Rohit Sharma
  • 31
  • 1
  • 6

4 Answers4

3

If you want to disable, you must use some negative trick with only css.You need to write some css to overwrite css.So, you can use transform unset like

.dropdown-menu.show {
  transform: unset !important;
}
NayDwe
  • 649
  • 3
  • 11
0

If I understand your query correctly, you're Bootstrap 4 dropdown is larger than you want. To resolve, you could add an overflow to the dropdown-menu

.menu-scroll {
  overflow-y: scroll;
  max-height: 200px;
}
billy.farroll
  • 1,903
  • 2
  • 15
  • 23
0

Add a class next to dropdown-menu, for example .menu-scrolling and then set custom css:


.menu-scrolling {
          min-height: 1oopx!important; /*Your value */
          max-height: 250px!important; /*Your value*/
          overflow-y: auto!important;
        }
NoLimits
  • 59
  • 1
  • 9
0

Put this line in your js file.

Popper.Defaults.modifiers.preventOverflow = { enabled: false };

for disable proper js.

and add some parameter in dropdown(data-flip="false",data-boundary="window" ) like this

          <a data-toggle="dropdown" href="#" data-flip="false" data-boundary="window" aria-expanded="true"  >
                <i class="icon-menu "></i>
                <span class="change-text">Select a Category</span>
            </a> 
Rohit Sharma
  • 31
  • 1
  • 6