1. 程式人生 > >【Bootstrap 4】按鈕組

【Bootstrap 4】按鈕組

Table of Contents

 

建立按鈕組(.btn-group) 

設定按鈕組大小(.btn-group-lg/.btn-group-sm)

設定按鈕組垂直(.btn-group-vertical)

內嵌按鈕組及下拉選單

拆分按鈕下拉選單

​ 

Table of Contents

建立按鈕組(.btn-group) 

設定按鈕組大小(.btn-group-lg/.btn-group-sm)

設定按鈕組垂直(.btn-group-vertical)

內嵌按鈕組及下拉選單

拆分按鈕下拉選單

垂直按鈕組及下拉選單


 


建立按鈕組(.btn-group) 

設定按鈕組大小(.btn-group-lg/.btn-group-sm)

設定按鈕組垂直(.btn-group-vertical)

<div class="btn-group btn-group-lg btn-group-vertical">
     <button type="button" class="btn btn-primary">Apple</button>
     <button type="button" class="btn btn-primary">Samsung</button>
     <button type="button" class="btn btn-primary">Sony</button>
</div>

 

內嵌按鈕組及下拉選單

<div class="btn-group">
     <button type="button" class="btn btn-primary">Apple</button>
     <button type="button" class="btn btn-primary">Samsung</button>
     <div class="btn-group">
          <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
              Sony
          </button>
          <div class="dropdown-menu">
               <a class="dropdown-item" href="#">Tablet</a>
               <a class="dropdown-item" href="#">SmartPhone</a>
          </div> 
     </div>
</div>

 

拆分按鈕下拉選單

 <div class="btn-group">
     <button type="button" class="btn btn-primary">Sony</button>
     <button type="button" 
      class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown">
         <span class="caret"></span>
     </button>
     <div class="dropdown-menu">
         <a class="dropdown-item" href="#">Tablet</a>
         <a class="dropdown-item" href="#">Smartphone</a>
     </div>
 </div>

 

垂直按鈕組及下拉選單

<div class="btn-group-vertical">
    <button type="button" class="btn btn-primary">Apple</button>
    <button type="button" class="btn btn-primary">Samsung</button>
    <div class="btn-group">
        <button type="button" class="btn btn-primary dropdown-toggle" 
         data-toggle="dropdown">
             Sony
        </button>
        <div class="dropdown-menu">
            <a class="dropdown-item" href="#">Tablet</a>
            <a class="dropdown-item" href="#">SmartPhone</a>
        </div>
    </div>
</div>