Making button go full-width?

后端 未结 10 1210
臣服心动
臣服心动 2020-12-22 17:18

I want a button to take up the full width of the column, but having difficulties...

相关标签:
10条回答
  • 2020-12-22 17:41
    <div class="col-md-9">
        <button class="btn btn-block btn-primary" type="button">Block level button</button>
    </div>
    

    In Bootstrap 3, this should be all you need. I believe btn-large was overriding the width of btn-block.

    0 讨论(0)
  • 2020-12-22 17:42

    use

    <div class="btn-group btn-group-justified">
      ...
    </div>
    

    but it only works for <a> elements and not <button> elements.

    see: http://getbootstrap.com/components/#btn-groups-justified

    0 讨论(0)
  • 2020-12-22 17:46

    You should add these styles to a CSS sheet

    div .no-padding {
      padding:0;
    }
    
    button .full-width{
      width:100%;
      //display:block; //only if you're having issues
    }
    

    Then change add the classes to your code

    <div class="span9 btn-block no-padding">
        <button class="btn btn-large btn-block btn-primary full-width" type="button">Block level button</button>
    </div>
    

    I haven't tested this and I'm not 100% sure what you want, but I think this will get you close.

    0 讨论(0)
  • 2020-12-22 17:49

    Bootstrap / CSS

    Use col-12, btn-block, w-100, form-control or width:100%

    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
    
             <button class="btn btn-success col-12">
                 class="col-12"
             </button>
        
             <button class="btn btn-primary w-100">
                 class="w-100"
             </button>
    
             <button class="btn btn-secondary btn-block">
                 class="btn-block"
             </button>
             
             <button class="btn btn-success form-control">
                 class="form-control"
             </button>
             
             <button class="btn btn-danger" style="width:100%">
                 style="width:100%"
             </button>

    0 讨论(0)
提交回复
热议问题