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!