Bootstrap has 7 different types of buttons with contextual classes from which we can create buttons easily by using these classes (.btn-default, .btn-success, .btn-danger, .btn-primary, .btn-info, .btn-warning, .btn-link).
Bootstrap具有上下文類型的 7種不同類型的按鈕 ,我們可以通過使用這些類輕松地創建按鈕( .btn-default , .btn-success , .btn-danger , .btn-primary , .btn-info , .btn-警告 , .btn-link )。
Example Code:
示例代碼:
<button type="button" class="btn btn-default">Button Default</button>
<button type="button" class="btn btn-primary">Button Primary</button>
<button type="button" class="btn btn-success">Button Success</button>
<button type="button" class="btn btn-info">Button Info</button>
<button type="button" class="btn btn-warning">Button Warning</button>
<button type="button" class="btn btn-danger">Button Danger</button>
<button type="button" class="btn btn-link">Button Link</button>
We can also make different size of buttons by using different button size classes (.btn-sm, .btn-lg, .btn-md, .btn-xs).
我們還可以通過使用不同的按鈕大小類( .btn-sm , .btn-lg , .btn-md , .btn-xs )來制作不同大小的按鈕。
Example Code:
示例代碼:
<button type="button" class="btn btn-primary btn-lg">Large button</button>
<button type="button" class="btn btn-default btn-md">Mediumbutton</button>
<button type="button" class="btn btn-success btn-sm">Small button </button>
<button type="button" class="btn btn-danger btn-xs">extraSmall button </button>
Here we also have a .btn-block level button spans the entire width of the parent element.
在這里,我們還有一個.btn塊級按鈕,它跨越父元素的整個寬度。
Example Code:
示例代碼:
<button type="button" class="btn btn-primary btn-block">Button 1</button>
<button type="button" class="btn btn-danger btn-lgbtn-block">Button 2</button>
A button can be set to an .active class (appear pressed) or a .disabled class (unclickable) state.
可以將按鈕設置為.active類(按顯示)或.disabled類( 不可單擊)狀態。
Example Code:
示例代碼:
<button type="button" class="btn btn-primary active">Active Primary</button>
<button type="button" class="btn btn-primary disabled">Disabled Primary</button>
Result
結果

Conclusion:
結論:
In this article, we have learnt about different button classes with contextual class, button size class, block button classes and active & disabled classes in Bootstrap. If you have doubt/query, feel free to ask in the comment box.
在本文中,我們了解了Bootstrap中不同的按鈕類,包括上下文類 , 按鈕大小類,塊按鈕類以及活動和禁用類 。 如果您有疑問/疑問,請隨時在評論框中提問。
翻譯自: https://www.includehelp.com/html/types-of-buttons-using-classes-in-bootstrap.aspx