Detailed introduction to Bootstrap button group

零下一度
Release: 2017-07-17 14:28:35
Original
1694 people have browsed it

The use of a single button in a Web page sometimes does not meet our business needs. We often see multiple buttons used together, such as a set of small icon buttons in a rich text editor. This article will introduce in detail the Bootstrap button group

How to use

The button group, like the drop-down menu component, needs to rely on the button.js plug-in to run properly. However, we can also directly call only the bootstrap.js file. Because this file has integrated button.js plug-in function

Similarly, because Bootstrap’s component interaction effects all rely on plug-ins written by the jQuery library, jquery.js must be loaded before using bootstrap.js Only then will the effect be produced

Document
Copy after login

Basic usage

The button group structure is very simple. Use a container named "btn-group" and put multiple buttons into this container

In order to convey the correct grouping of buttons to screen reader users, you need to provide an appropriateroleAttributes. For button groups, it should berole="group", for toolbar (toolbar) it should berole="toolbar"

In addition, button groups and toolbars An explicit label should be given, as most assistive technologies will not read them correctly despite setting the correctroleattributes. You can usearia-labelor aria-labelledby

In addition to the

Copy after login


Button Toolbar

In the rich text editor, group button groups together, such as copy, cut and paste a group; left-aligned, middle-aligned, Align right and align one group to the other. The Bootstrap framework button toolbar also provides such a production method. You only need to place the button group "btn-group" in a large container "btn-toolbar" by group

Copy after login


Button size

In the blog post introducing form buttons, we know that buttons are divided into three categories: btn-lg, btn-sm and btn-xs name to adjust the padding, font-size, line-height and border-radius property values to change the button size. Then we can also use a similar method to determine the size of the button group:

☑ .btn-group-lg: Large button group

☑ .btn-group-sm: Small button group

☑ .btn-group-xs: Ultra-small button group

Just append the corresponding class name to the ".btn-group" class name to get button groups of different sizes

Copy after login


Nested Grouping

Many times, we often arrange drop-down menus and ordinary button groups in Together, we achieve an effect similar to a navigation menu. When using it, you only need to change the "dropdown" container of the original drop-down menu to "btn-group" and put it at the same level as the ordinary button


Vertical arrangement

By default, button groups are displayed horizontally. But in actual application, you will always encounter the effect of vertical display. This style is also provided in the Bootstrap framework. Just change the "btn-group" class name of the horizontal grouping to "btn-group-vertical"

Copy after login


Equally divided button

The effect of the equal divided button is particularly practical on the mobile terminal. The entire button group width is 100% of the container, and each button in the button group divides the entire container width equally. For example, if there are five buttons in the button group, then each button is 20% wide, if there are four buttons, then each button is 25% wide, and so on. Equally divided buttons are also common. It is called an adaptive group button, and its implementation method is also very simple. You only need to append a "btn-group-justified" class name to the button group "btn-group"

. The implementation principle is very simple. Simulate "btn-group-justified" as a table (display:table), and simulate the buttons inside as table cells (display:table-cell)

 [Note] When making equal button groups , try to use thetag element to make buttons, because when using the

Copy after login

The above is the detailed content of Detailed introduction to Bootstrap button group. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Previous article:Bootstrap button drop-down menu example tutorial Next article:Detailed introduction to h5 semantic tags
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!