Implementing Multilevel Dropdowns with Twitter Bootstrap 2
Twitter Bootstrap 2 natively lacks the ability to create multilevel dropdown menus. To overcome this limitation, developers have devised creative workarounds using additional CSS and HTML elements.
Custom CSS Solution
One approach involves adding custom CSS to define the appearance and behavior of sub-menus:
.dropdown-menu .sub-menu { left: 100%; position: absolute; top: 0; visibility: hidden; margin-top: -1px; } .dropdown-menu li:hover .sub-menu { visibility: visible; display: block; } .navbar .sub-menu:before { border-bottom: 7px solid transparent; border-left: none; border-right: 7px solid rgba(0, 0, 0, 0.2); border-top: 7px solid transparent; left: -7px; top: 10px; } .navbar .sub-menu:after { border-top: 6px solid transparent; border-left: none; border-right: 6px solid #fff; border-bottom: 6px solid transparent; left: 10px; top: 11px; left: -6px; }
This CSS positions sub-menus adjacent to their parent menu items and calculates their dimensions and positions accordingly.
Note: This approach was deprecated in Bootstrap 3 and is no longer necessary in later versions.
The above is the detailed content of How Can I Create Multilevel Dropdown Menus with Twitter Bootstrap 2?. For more information, please follow other related articles on the PHP Chinese website!