Center Twitter Bootstrap 3 Glyphicons in buttons

后端 未结 10 2011
情话喂你
情话喂你 2020-12-13 17:16

I am now using Twitter Bootstrap 3 RC2 as well as Twitter Bootstrap which has moved into a separate repository. I have noticed, if used in a button with text the icon is no

相关标签:
10条回答
  • 2020-12-13 17:49

    Problem: Glyph icon was 2 px too high above the button text. Fixed it as follows using examples here. Thank you (Alastair Maw).

    I managed to get mine working as follows:

    HTML

    <div class="col-xs-12">
        <a title="" class="btn btn-block btn-info oa-btn-spacer_homepage oa-ellipsis" role="button" href="default.aspx?action=page&name=creditcard">
            <span class="glyphicon glyphicon-credit-card glyph_Credit"></span> Update Your Credit Card and Billing Information
        </a>
    </div>
    

    CSS

    #panelTopic  .glyph_Credit {
        vertical-align: middle;
        display: inline-block;
        padding-bottom:6px;
    }
    
    0 讨论(0)
  • 2020-12-13 17:49

    Other way

    <button class="btn default" id="IdBack">
      <i class="glyphicon glyphicon-hand-left"></i> 
      <b>Back</b>
    </button>
    
    0 讨论(0)
  • 2020-12-13 17:52

    Move the text out of the <span> with the glyphicon and apply vertical-align: middle; to the <span>

      <button class="btn btn-default">
        <span class="glyphicon glyphicon-th" style="vertical-align: middle;"></span> Centered
      </button>
    

    Demo

    This works in Bootstrap 4 with Font Awesome icons like so

    <button class="btn btn-default" style="vertical-align: middle;">
        <i class="fa fa-times"></i> Centered
    </button>
    
    0 讨论(0)
  • 2020-12-13 17:54

    Apply a vertical-align: -{N}px; style on the .glyphicon-th to shift it N pixels up/down.

    0 讨论(0)
  • 2020-12-13 17:54
    <button class="btn btn-default">
              <span class="glyphicon glyphicon-th" style="font-size: 14px;"> </span>
              <span style="font-size: 17px;">Not Centered</span>
        </button>
    

    please increase or decrease the font size according to your requirement

    0 讨论(0)
  • 2020-12-13 18:01

    Add a margin of the specific pixels or percentage. In my app, this worked beautifully, based on the dimensions of the area.

    CSS:

    .someWrapperClass button span {
        margin-top: 120%;
    }
    

    HTML:

    <div class="someWrapperClass">
        <button type="button" ng-click="SomeMethod()">
            <span class="glyphicon glyphicon-chevron-left"></span>
        </button>
    </div>
    
    0 讨论(0)
提交回复
热议问题