Abstract: Bootstrap button styles mainly include: basic button, default button, main button, success button, information button, warning button, danger button , link button.
1. Introduction to buttons:
Buttons are also one of the core contents of the Bootstrap framework. Because buttons are an indispensable thing in Web production.
Moreover, different Web pages have different button styles, and even the same Web website or application has multiple button styles, such as different button colors, sizes, and states.
<button>基础按钮.btn</button> <button>默认按钮.btn-default</button> <button>主要按钮.btn-primary</button> <button>成功按钮.btn-success</button> <button>信息按钮.btn-info</button> <button>警告按钮.btn-warning</button> <button>危险按钮.btn-danger</button> <button>链接按钮.btn-link</button>
2. Basic buttons
Bootstrap Framework V3 The basic buttons of the .x version are the same as the basic buttons of the V2.x version, and are implemented through the class name "btn".
The difference is that the V3.x version is much simpler, and a large number of special effects in CSS3 in the V2.x version have been removed, such as text-shadow and gradient background ), border shadow (box-shadow), etc.
The Bootstrap framework takes into account the parsing differences of different browsers and performs relatively safe compatibility processing so that the button effects are basically the same in different browsers.
For the source code, please refer to lines 1992 to 2010 of the bootstrap.css file:
The buttons of the Bootstrap framework are very simple to use. The usage method is as follows:
<button>我是一个基本按钮</button>
3. Default button
The Bootstrap framework first passes the base class name ".btn" defines a basic button style, and then ".btn-default" defines a default button style.
The default button style is based on the basic button style, with the background color, border color and text color modified.
For the source code, please refer to lines 2040 to 2044 of the bootstrap.css file
Using the default button style is also very simple, just add the basic button "btn" Basically, just add the class name "btn-default":
<button>默认按钮</button>
4. Multi-label support (multiple label production buttons)
General production In addition to using the
Similarly, when making buttons in the Bootstrap framework, in addition to the label elements just mentioned, you can also use them on other label elements. The only thing you need to pay attention to is that you need to use the label element when making the button. Add the class name "btn".
If you don’t add it, there will be no button effect.
<button>button标签按钮</button><input><a>a标签按钮</a><span>span标签按钮</span><p>p标签按钮</p>
Although the button style can be achieved using any label element in the Bootstrap framework, I personally do not recommend using it in this way, in order to avoid Due to browser compatibility issues, I strongly recommend using button or a tags to make buttons.
5. Customize buttons of different styles
As mentioned at the beginning of the introduction to buttons, Web pages may have different button styles. Then the Bootstrap framework is also considered.
In addition to the default button style in the Bootstrap framework, there are six other button styles. Each style is actually the same. The difference is the background color, border color and text color of the button.
Different button styles in the Bootstrap framework are implemented through different class names. During use, developers only need to choose different class names:
It is very simple to use, just like the default button introduced earlier, you only need to add the corresponding to the basic button ".btn" Class name , you can get the desired button style. Such as:
<button>基础按钮.btn</button><button>默认按钮.btn-default</button><button>主要按钮.btn-primary</button><button>成功按钮.btn-success</button><button>信息按钮.btn-info</button><button>警告按钮.btn-warning</button><button>危险按钮.btn-danger</button><button>链接按钮.btn-link</button>
六、按钮大小
在Bootstrap框架中,对于按钮的大小,也是可以定制的。类似于input一样,通过在基础按钮“.btn”的基础上追加类名来控制按钮的大小。
在Bootstrap框架中提供了三个类名来控制按钮大小:
从上表中不难发现,在Bootstrap框架中控制按钮的大小都是通过修改按钮的padding、line-height、font-size和border-radius几个属性。
源码查阅bootstrap.css文件中第2319行~第2339行
那么在实际使用中,这几个类名可以配合按钮中其他颜色类名一起使用,但唯一一点不能缺少“.btn”类名:
<button>大型按钮.btn-lg</button> <button>正常按钮</button> <button>小型按钮.btn-sm</button>
七、块状按钮
Bootstrap框架中提供了一个类名“btn-block”。
按钮使用这个类名就可以让按钮充满整个容器,并且这个按钮不会有任何的padding和margin值。在实际当中,常把这种按钮称为块状按钮。
具体源码请查阅bootstrap.css文件第2340行~第2353行:
使用方法和前面的类似,只需要在原按钮类名上添加“.btn-block”类名,当然“.btn”类名是不可或缺的:
<button>大型按钮.btn-lg</button><button>正常按钮</button><button>小型按钮.btn-sm</button><button>超小型按钮.btn-xs</button>
八、按钮状态——活动状态
Bootstrap框架针对按钮的状态做了一些特殊处理。在Bootstrap框架中针对按钮的状态效果主要分为两种:活动状态和禁用状态。
Bootstrap按钮的活动状态主要包括按钮的悬浮状态(:hover),点击状态(:active)和焦点状态(:focus)几种。
源码请查看bootstrap.css文件第2011行~第2029行
不同风格下的按钮都具有这几种状态效果,只是颜色做了一定的调整,我们以默认风格(btn-default)为例:
源码请查看bootstrap.css文件第2045行~第2058行
当按钮处理正在点击状态(也就是鼠标按下的未松开的状态),对于
<button>基础按钮.btn</button> <button>默认按钮.btn-default</button> <button>主要按钮.btn-primary</button> <button>成功按钮.btn-success</button> <button>信息按钮.btn-info</button> <button>警告按钮.btn-warning</button> <button>危险按钮.btn-danger</button> <button>链接按钮.btn-link</button>
九、按钮状态——禁用状态
和input等表单控件一样,在Bootstrap框架的按钮中也具有禁用状态的设置。
禁用状态与其他状态按钮相比,就是背景颜色的透明度做了一定的处理,opcity的值从100%调整为65%。
在Bootstrap框架中,要禁用按钮有两种实现方式:
方法1:在标签中添加disabled属性
方法2:在元素标签中添加类名“disabled”
两者的主要区别是:
“.disabled”样式不会禁止按钮的默认行为,比如说提交和重置行为等。
如果想要让这样的禁用按钮也能禁止按钮的默认行为,则需要通过JavaScript这样的语言来处理。
对于标签也存在类似问题,如果通过类名“.disable”来禁用按钮,其链接行为是无法禁止。
而在元素标签中添加“disabled”属性的方法是可以禁止元素的默认行为的。
<button>通过disabled属性禁用按钮</button><button>通过添加类名disabled禁用按钮</button><button>未禁用的按钮</button>
The above is the detailed content of What are the styles of bootstrapt buttons?. For more information, please follow other related articles on the PHP Chinese website!

Advantages of integrating Bootstrap into React projects include: 1) rapid development, 2) consistency and maintainability, and 3) responsive design. By directly introducing CSS files or using the React-Bootstrap library, you can use Bootstrap's components and styles efficiently in your React project.

Bootstrap is a framework developed by Twitter to help quickly build responsive, mobile-first websites and applications. 1. Ease of use and rich component libraries make development faster. 2. The huge community provides support and solutions. 3. Introduce and use class names to control styles through CDN, such as creating responsive grids. 4. Customizable styles and extension components. 5. Advantages include rapid development and responsive design, while disadvantages are style consistency and learning curve.

Bootstrapisafree,open-sourceCSSframeworkthatsimplifiesresponsiveandmobile-firstwebsitedevelopment.Itofferspre-styledcomponentsandagridsystem,streamliningthecreationofaestheticallypleasingandfunctionalwebdesigns.

What makes web design easier is Bootstrap? Its preset components, responsive design and rich community support. 1) Preset component libraries and styles allow developers to avoid writing complex CSS code; 2) Built-in grid system simplifies the creation of responsive layouts; 3) Community support provides rich resources and solutions.

Bootstrap accelerates web development, and by providing predefined styles and components, developers can quickly build responsive websites. 1) It shortens development time, such as completing the basic layout within a few days in the project. 2) Through Sass variables and mixins, Bootstrap allows custom styles to meet specific needs. 3) Using the CDN version can optimize performance and improve loading speed.

Bootstrap is an open source front-end framework, and its main function is to help developers quickly build responsive websites. 1) It provides predefined CSS classes and JavaScript plug-ins to facilitate the implementation of complex UI effects. 2) The working principle of Bootstrap relies on its CSS and JavaScript components to realize responsive design through media queries. 3) Examples of usage include basic usage, such as creating buttons, and advanced usage, such as custom styles. 4) Common errors include misspelling of class names and incorrectly introducing files. It is recommended to use browser developer tools to debug. 5) Performance optimization can be achieved through custom build tools, best practices include predefined using semantic HTML and Bootstrap

Bootstrap implements responsive design through grid systems and media queries, making the website adapted to different devices. 1. Use a predefined class (such as col-sm-6) to define the column width. 2. The grid system is based on 12 columns, and it is necessary to note that the sum does not exceed 12. 3. Use breakpoints (such as sm, md, lg) to define the layout under different screen sizes.

Bootstrap is an open source front-end framework for rapid development of responsive websites and applications. 1. It provides the advantages of responsive design, consistent UI components and rapid development. 2. The grid system uses flexbox layout, based on 12-column structure, and is implemented through classes such as .container, .row and .col-sm-6. 3. Custom styles can be implemented by modifying SASS variables or overwriting CSS. 4. Commonly used JavaScript components include modal boxes, carousel diagrams and folding. 5. Optimization performance can be achieved by loading only necessary components, using CDN, and compressing merge files.


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

Atom editor mac version download
The most popular open source editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

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