Home > Web Front-end > JS Tutorial > Bootstrap introductory book (4) Menus, buttons and navigation_javascript skills

Bootstrap introductory book (4) Menus, buttons and navigation_javascript skills

WBOY
Release: 2016-05-16 15:14:57
Original
1327 people have browsed it

What we are going to learn next are some components provided by Bootstrap. These components are very simple to use, can help us build a website quickly and conveniently, and can achieve a good display effect. What we need to pay attention to most is: the structure of HTML and the classes and attributes that bootstrap provides to add to the structure.

The interactive functions of these components rely on the jQuery library, so jQuery.js must also be introduced, and it must be before Bootstrap.js. If it is officially launched, just use the compressed version as follows:

<script src="../js/jquery-min-1.11.3.js"></script><script src="../js/bootstrap.min.js"></script>
Copy after login

Menu

Basic usage

In the official documentation, the drop-down menu component we see looks like this:

<div class="dropdown"> <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> 下拉菜单<span class="caret"></span> </button> <ul class="dropdown-menu" aria-labelledby="dropdownMenu1"> <li><a href="#">菜单项1</a></li> <li><a href="#">菜单项2</a></li> </ul></div>
Copy after login

So, which attributes are necessary to control behavior? Which part is used for modification?

Let’s simplify this code ourselves:

<div class="dropdown"> <button class="dropdown-toggle"data-toggle="dropdown">下拉菜单</button> <ul class="dropdown-menu" > <li>菜单项1</li> <li>菜单项2</li> </ul></div>
Copy after login

Let’s take a look at the comparison before and after simplification:

When using the drop-down menu component in the Bootstrap framework, it is very important to use the correct structure. If the structure and class name are not used correctly, it will directly affect whether the component can be used normally. After our above simplification, we can finally see that the core requirements are as follows:

Use a container named .dropdown to wrap the entire drop-down menu element. In the example:

uses a
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template