An in-depth analysis of the drop-down menu component in Bootstrap

青灯夜游
Release: 2021-02-18 22:45:26
forward
2438 people have browsed it

An in-depth analysis of the drop-down menu component in Bootstrap

Related recommendations: "bootstrap Tutorial"

The drop-down menu component in the bootstrap framework is an independent component. According to different version, its corresponding file:

less. The corresponding source code file is: dropdowns.less

sass. The corresponding source code file is: _dropdowns. scss

When using the drop-down menu built by bootstrap, you must call the bootstrap.js file provided by the bootstrap framework. For the uncompiled version, you can find a file named dropdown.js under js, and you can also call this file. You can also call the compressed file bootstrap.min.js

Since the interactive effects of bootstrap components all rely on plug-ins written by the jQuery library, you must be sure before using bootstrap.min.js First load jQuery.min.js

Example on the official website:

Copy after login

Detailed explanation:

1. Use a dropdown The container wraps the entire drop-down menu element

Copy after login

2, uses the

Copy after login

css style:

.dropdown-header { display: block; padding: 3px 20px; font-size: 12px; line-height: 1.42857143; color: #999; }
Copy after login

The drop-down menu in the bootstrap framework is left aligned by default. If you want the drop-down menu to be right-aligned relative to the parent container, you can add a class to dropdown-menu. dropdown -menu-right, note that starting from v3.1.0, it is no longer recommended to use the .pull-right class for drop-down menus

Copy after login
.dropdown-menu-right { right: 0; left: auto; } .dropdown{ float: left; }
Copy after login

Menu item status

Drop-down menu The default states include hover state: hover and focus state: focus

.dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus { color: #262626; text-decoration: none; background-color: #f5f5f5; }
Copy after login

The drop-down menu also has the current state and the disabled state. To use these two states, you only need to add the corresponding class name to the corresponding menu item

Copy after login

CSS:

.dropdown-menu > .active > a, .dropdown-menu > .active > a:hover, .dropdown-menu > .active > a:focus { color : #fff; text-decoration : none; background-color : #428bca; outline : 0; } .dropdown-menu > .disabled > a, .dropdown-menu > .disabled > a:hover, .dropdown-menu > .disabled > a:focus { color: #999; } .dropdown-menu > .disabled > a:hover, .dropdown-menu > .disabled > a:focus { text-decoration: none; cursor: not-allowed; background-color: transparent; background-An in-depth analysis of the drop-down menu component in Bootstrap: none; filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); }
Copy after login

For more programming-related knowledge, please visit:Programming Video! !

The above is the detailed content of An in-depth analysis of the drop-down menu component in Bootstrap. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Previous article:A deep dive into the grid system in Bootstrap Next article:An in-depth analysis of panel components in Bootstrap
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
Latest Issues
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!