Home  >  Article  >  Web Front-end  >  Detailed explanation of how to use Bootstrap button examples (code examples)

Detailed explanation of how to use Bootstrap button examples (code examples)

PHPz
PHPzOriginal
2017-08-17 13:55:312176browse

This chapter will explain how to use Bootstrap buttons through examples. Any element with class .btn will inherit the default appearance of a rounded gray button. But Bootstrap provides some options to style the buttons. Detailed explanation through the examples of this article

[Related video recommendations: Bootstrap tutorial]

Bootstrap button

This chapter will explain how to use Bootstrap buttons through examples. Any element with class .btn will inherit the default appearance of a rounded gray button. However, Bootstrap provides some options to define the style of buttons, as shown in the following table:

The following styles can be used on 3499910bf9dac5ae3c52d5ede7383485, bb9345e55eb71822850ff156dfde57c8, or d5fd7aea971a85678ba271703566ebfd elements:

The following example demonstrates all the above button classes:

<!-- 标准的按钮 -->
<button type="button" class="btn btn-default">默认按钮</button>
<!-- 提供额外的视觉效果,标识一组按钮中的原始动作 -->
<button type="button" class="btn btn-primary">原始按钮</button>
<!-- 表示一个成功的或积极的动作 -->
<button type="button" class="btn btn-success">成功按钮</button>
<!-- 信息警告消息的上下文按钮 -->
<button type="button" class="btn btn-info">信息按钮</button>
<!-- 表示应谨慎采取的动作 -->
<button type="button" class="btn btn-warning">警告按钮</button>
<!-- 表示一个危险的或潜在的负面动作 -->
<button type="button" class="btn btn-danger">危险按钮</button>
<!-- 并不强调是一个按钮,看起来像一个链接,但同时保持按钮的行为 -->
<button type="button" class="btn btn-link">链接按钮</button>

Effect

Button size

The following table lists the classes for obtaining buttons of various sizes:

<p>
 <button type="button" class="btn btn-primary btn-lg">大的原始按钮</button>
 <button type="button" class="btn btn-default btn-lg">大的按钮</button>
</p>
<p>
 <button type="button" class="btn btn-primary">默认大小的原始按钮</button>
 <button type="button" class="btn btn-default">默认大小的按钮</button>
</p>
<p>
 <button type="button" class="btn btn-primary btn-sm">小的原始按钮</button>
 <button type="button" class="btn btn-default btn-sm">小的按钮</button>
</p>
<p>
 <button type="button" class="btn btn-primary btn-xs">特别小的原始按钮</button>
 <button type="button" class="btn btn-default btn-xs">特别小的按钮</button>
</p>
<p>
 <button type="button" class="btn btn-primary btn-lg btn-block">块级的原始按钮</button>
 <button type="button" class="btn btn-default btn-lg btn-block">块级的按钮</button>
</p>

Effect

Button state

Bootstrap provides classes for activation, deactivation and other button states, which will be explained in detail below.

Activation state

The button will have a pressed appearance (dark background, dark border, shadow) when activated.

The following table lists the classes that make button elements and anchor elements active:

<p>
 <button type="button" class="btn btn-default btn-lg ">默认按钮</button>
 <button type="button" class="btn btn-default btn-lg active">激活按钮</button>
</p>
<p>
 <button type="button" class="btn btn-primary btn-lg ">原始按钮</button>
 <button type="button" class="btn btn-primary btn-lg active">激活的原始按钮</button>
</p>

DisabledState

When you disable a button, it becomes 50% lighter and loses its gradient.

The following table lists the classes that disable button elements and anchor elements:

The following example demonstrates this:

<p>
 <button type="button" class="btn btn-default btn-lg">默认按钮</button>
 <button type="button" class="btn btn-default btn-lg" disabled="disabled">禁用按钮</button>
</p>
<p>
 <button type="button" class="btn btn-primary btn-lg ">原始按钮</button>
 <button type="button" class="btn btn-primary btn-lg" disabled="disabled">禁用的原始按钮</button>
</p>
<p>
 <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="btn btn-default btn-lg" role="button">链接</a>
 <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="btn btn-default btn-lg disabled" role="button">禁用链接</a>
</p>
<p>
 <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="btn btn-primary btn-lg" role="button">原始链接</a>
 <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="btn btn-primary btn-lg disabled" role="button">禁用的原始链接</a>
</p>

Effect

Button label

You can use 3499910bf9dac5ae3c52d5ede7383485, Use button class on bb9345e55eb71822850ff156dfde57c8 or d5fd7aea971a85678ba271703566ebfd elements. However, it is recommended that you use the button class on the bb9345e55eb71822850ff156dfde57c8 element to avoid cross-browser inconsistencies.

The following example demonstrates this:

<a class="btn btn-default" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" role="button">链接</a>
<button class="btn btn-default" type="submit">按钮</button>
<input class="btn btn-default" type="button" value="输入">
<input class="btn btn-default" type="submit" value="提交">

The above is a detailed example of using Bootstrap buttons introduced by the editor. I hope it will be helpful to you. If you have any questions, please Leave me a message and I will reply to you in time. I would also like to thank you all for your support of the php website!

The above is the detailed content of Detailed explanation of how to use Bootstrap button examples (code examples). For more information, please follow other related articles on the PHP Chinese website!

Statement:
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