This chapter will explain how to use the Bootstrap class to add a drop-down menu to a button. To add a drop-down menu to a button, simply place the button and drop-down menu in a .btn-group . You can also useto indicate that the button acts as a drop-down menu.
The following example demonstrates a basic simple button drop-down menu:
Using the drop-down menu in the Bootstrap framework When using a component, it is very important to use its structure correctly. If the structure and class name are not used correctly, it will directly affect whether the component can be used normally
1. Use a container named "dropdown" to wrap the entire Drop-down menu element
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 dropdown-menu on "dropdown-menu" "dropdown-menu-right" class name
.dropdown-menu-right { right: 0; left: auto; }
Copy after login
Since
is a block-level element by default, filling the parent width. Here, you need to set inline-block and margin-left for the element so that its content stretches the width and is a certain distance from the left side
The default states of drop-down menu items are 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
In addition to the above two states, the drop-down menu items also have the current state (.active) and the disabled state (.disabled). To use these two states, you only need to add the corresponding class name
The above is the detailed content of Example tutorial of Bootstrap drop-down menu. For more information, please follow other related articles on the PHP Chinese 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