Home > Web Front-end > CSS Tutorial > How to Create a Scrollable Menu with Bootstrap Without Expanding Its Container?

How to Create a Scrollable Menu with Bootstrap Without Expanding Its Container?

Patricia Arquette
Release: 2024-10-27 05:36:29
Original
1062 people have browsed it

How to Create a Scrollable Menu with Bootstrap Without Expanding Its Container?

Scrollable Menu with Bootstrap - Menu Extending Container

Issue

Using the provided method to create a scrollable menu with Bootstrap results in the menu expanding its container when it seharusnya not. How can this be resolved?

Solution for Bootstrap 5

For Bootstrap 5, apply the following CSS:

.dropdown-menu {
    max-height: 280px;
    overflow-y: auto;
}
Copy after login

Solution for Bootstrap 4

For Bootstrap 4, apply the same CSS as above.

Alternative Solution for Bootstrap 3

Alternatively, for Bootstrap 3, add the following CSS and HTML:

CSS

.scrollable-menu {
    height: auto;
    max-height: 200px;
    overflow-x: hidden;
}
Copy after login

HTML

<ul class="dropdown-menu scrollable-menu" role="menu">
    <li><a href="#">Action</a></li>
    <li><a href="#">Another action</a></li>
    <li><a href="#">Something else here</a></li>
    <!-- ... -->
    <li><a href="#">Action</a></li>
    <li><a href="#">Another action</a></li>
</ul>
Copy after login

The above is the detailed content of How to Create a Scrollable Menu with Bootstrap Without Expanding Its Container?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template