csstwitter-bootstrap

Bootstrap: vertically align paragraph text and buttons


I have text in a paragraph with a button a element:

<p>
  <a class="btn btn-default" href="#">Take exam</a> 
  <span class="text-muted">Available after reading course material</span>
</p>

However, this renders with the two not vertically aligned.

enter image description here

What is the best way to align the text baseline here?

Fiddle at http://jsfiddle.net/0j20stbh/


Solution

  • Using the same styling as the .btn would probably be a good approach. Example with disabled .btn

    <p>
        <a class="btn btn-default" href="#">Take exam</a> 
        <span class="text-muted btn" disabled="true">Text</span>
    </p>
    


    Or make a class of .btn-align with the same attributes. Example

    CSS

    .btn-align {
        padding: 6px 12px;
        line-height: 1.42857143;
        vertical-align: middle;
    
    }
    

    HTML

    <p>
      <a class="btn btn-default" href="#">Take exam</a> 
      <span class="text-muted btn-align">Available after reading course material</span>
    </p>