Chapter 7 Menu Button Icon Component_Javascript Skills
Bootstrap, from Twitter, is currently the most popular front-end framework. Bootstrap is based on HTML, CSS, and JAVASCRIPT. It is simple and flexible, making web development faster.
Learning points:
1. Small icon component
2. Drop-down menu component
3. Button group component
4. Button drop-down menu
In this lesson we will mainly study the three component functions of Bootstrap: small icon component, drop-down menu component and various button components.
1. Small icon component
Bootstrap provides 263 free small icons (counted twice). For details, please refer to the component link of the Chinese official website:
http://v3.bootcss.com/components/#glyphicons.
Some icons are as follows:
can be used with or tags, as follows:
//使用小图标 <i class="glyphicon glyphicon-star"></i> <span class="glyphicon glyphicon-star"></span> //也可以结合按钮 <button class="btn btn-default btn-lg"> <span class="glyphicon glyphicon-star"></span> </button> <button class="btn btn-default btn"> <span class="glyphicon glyphicon-star"></span> </button> <button class="btn btn-default btn-sm"> <span class="glyphicon glyphicon-star"></span> </button> <button class="btn btn-default btn-xs"> <span class="glyphicon glyphicon-star"></span> </button>
2. Drop-down menu component
The drop-down menu is to click an element or button to trigger the hidden list to be displayed.
//基本格式 <div class="dropdown"> <button class="btn btn-default" data-toggle="dropdown"> 下拉菜单 <span class="caret"></span> </button> <ul class="dropdown-menu"> <li> <a href="#">首页</a> </li> <li> <a href="#">资讯</a> </li> <li> <a href="#">产品</a> </li> <li> <a href="#">关于</a> </li> </ul> </div>
Buttons and menus need to be wrapped in a .dropdown container, and buttons as clicked elements need to be set with data-toggle="dropdown" to be effective. For the menu section, set class="dropdown-menu" to automatically hide and add fixed styles. Set class="caret" to indicate an arrow, which can be up or down.
//设置向上触发 <div class="dropup"> //菜单项居右对齐,默认值是 dropdown-menu-left <ul class="dropdown-menu dropdown-menu-right"> //设置菜单的标题,不要加超链接 <li class="dropdown-header">网站导航</li> //设置菜单的分割线 <li class="divider"></li> //设置菜单的禁用项 <li class="disabled"><a href="#">产品</a></li> //让菜单默认显示 <div class="dropdown open">
3. Button group component
Button group is multiple buttons integrated in a container to create a unique effect.
//基本格式 <div class="btn-group"> <button type="button" class="btn btn-default"> 左 </button> <button type="button" class="btn btn-default"> 中 </button> <button type="button" class="btn btn-default"> 右 </button> </div> //将多个按钮组整合起来便于管理 <div class="btn-toolbar"> <div class="btn-group"> <button type="button" class="btn btn-default"> 左 </button> <button type="button" class="btn btn-default"> 中 </button> <button type="button" class="btn btn-default"> 右 </button> </div> <div class="btn-group"> <button type="button" class="btn btn-default"> </button> <button type="button" class="btn btn-default"> </button> <button type="button" class="btn btn-default"> </button> </div> </div> //设置按钮组大小 <div class="btn-group btn-group-lg"> <div class="btn-group> <div class="btn-group btn-group-sm"> <div class="btn-group btn-group-xs"> //嵌套一个分组,比如下拉菜单 <div class="btn-group"> <button type="button" class="btn btn-default"> 左 </button> <button type="button" class="btn btn-default"> 中 </button> <button type="button" class="btn btn-default"> 右 </button> <div class="btn-group"> <button class="btn btn-default dropdown-toggle" data-toggle="dropdown"> 下拉菜单 <span class="caret"></span> </button> <ul class="dropdown-menu"> <li> <a href="#">首页</a> </li> <li> <a href="#">资讯</a> </li> <li> <a href="#">产品</a> </li> <li> <a href="#">关于</a> </li> </ul> </div> </div>
Note: Class="dropdown" is not implemented in
//设置按钮组垂直排列 <div class="btn-group-vertical"> //设置两端对齐按钮组,使用<a>标签 <div class="btn-group-justified"> <a type="button" class="btn btn-default">左</a> <a type="button" class="btn btn-default">中</a> <a type="button" class="btn btn-default">右</a> </div> //如果需要使用<button>标签,则需要对每个按钮进行群组 <div class="btn-group-justified"> <div class="btn-group"> <button type="button" class="btn btn-default"> 左 </button> </div> <div class="btn-group"> <button type="button" class="btn btn-default"> 中 </button> </div> <div class="btn-group"> <button type="button" class="btn btn-default"> 右 </button> </div> </div>
4. Button drop-down menu
This drop-down menu is actually the same as the second knowledge point, except that this one is in a group, and there is no need to declare class="dropdown" in
//群组按钮下拉菜单 <div class="btn-group"> <button type="button" class="btn btn-default dropdown-toggle"data-toggle="dropdown"> 下拉菜单 <span class="caret"></span> </button> <ul class="dropdown-menu"> <li> <a href="#">首页</a> </li> <li> <a href="#">资讯</a> </li> <li> <a href="#">产品</a> </li> <li> <a href="#">关于</a> </li> </ul> </div> //分裂式按钮下拉菜单 <div class="btn-group"> <button type="button" class="btn btn-default"> 下拉菜单 </button> <button type="button" class="btn btn-default dropdown-toggle"data-toggle="dropdown"> <span class="caret"></span> </button> <ul class="dropdown-menu"> <li> <a href="#">首页</a> </li> <li> <a href="#">资讯</a> </li> <li> <a href="#">产品</a> </li> <li> <a href="#">关于</a> </li> </ul> </div> //向上弹出式 <div class="btn-group dropup">
The above content is the menu button icon component of the BootStrap component introduced by the editor. I hope it will be helpful to everyone!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Article discusses creating, publishing, and maintaining JavaScript libraries, focusing on planning, development, testing, documentation, and promotion strategies.

The article discusses strategies for optimizing JavaScript performance in browsers, focusing on reducing execution time and minimizing impact on page load speed.

Frequently Asked Questions and Solutions for Front-end Thermal Paper Ticket Printing In Front-end Development, Ticket Printing is a common requirement. However, many developers are implementing...

The article discusses effective JavaScript debugging using browser developer tools, focusing on setting breakpoints, using the console, and analyzing performance.

This article explores effective use of Java's Collections Framework. It emphasizes choosing appropriate collections (List, Set, Map, Queue) based on data structure, performance needs, and thread safety. Optimizing collection usage through efficient

The article explains how to use source maps to debug minified JavaScript by mapping it back to the original code. It discusses enabling source maps, setting breakpoints, and using tools like Chrome DevTools and Webpack.

This tutorial will explain how to create pie, ring, and bubble charts using Chart.js. Previously, we have learned four chart types of Chart.js: line chart and bar chart (tutorial 2), as well as radar chart and polar region chart (tutorial 3). Create pie and ring charts Pie charts and ring charts are ideal for showing the proportions of a whole that is divided into different parts. For example, a pie chart can be used to show the percentage of male lions, female lions and young lions in a safari, or the percentage of votes that different candidates receive in the election. Pie charts are only suitable for comparing single parameters or datasets. It should be noted that the pie chart cannot draw entities with zero value because the angle of the fan in the pie chart depends on the numerical size of the data point. This means any entity with zero proportion

There is no absolute salary for Python and JavaScript developers, depending on skills and industry needs. 1. Python may be paid more in data science and machine learning. 2. JavaScript has great demand in front-end and full-stack development, and its salary is also considerable. 3. Influencing factors include experience, geographical location, company size and specific skills.
