locoboy
locoboy

Reputation: 38960

Vertically center bootstrap btn in .well class

I have a link that I want to center vertically in the .well class from the bootstrap framework and am using the class btn btn-danger on the anchor tag. Here's the pic below. I tried to use vertical-align:middle; but that doesn't seem to work. You can see that the space on the well isn't even on the top and the bottom.

enter image description here

Here is the HTML:

<div class="well">
   <%= link_to "Remove", thing, method: :delete, style: "font-size: 11px; float:right; ", :class => 'btn btn-danger'%>

</div>

Upvotes: 5

Views: 11433

Answers (2)

Sherbrow
Sherbrow

Reputation: 17379

It appears you shouldn't (or simply can't) vertically align a floating element.

Here is what i suggest :

<div class="well mywell">
    <div class="pull-right myfloater">
       <button class="btn btn-danger vcenter">Remove</button>    
    </div>
    <p><!-- things --></p>
</div>
.mywell{
   height: 150px;
}
.myfloater {
    line-height: 150px;
}
.vcenter{
    vertical-align: middle;
}

The live example : http://jsfiddle.net/Sherbrow/wxM5Z/2/

Edit

Better with line-heightapplied to the floating element.

Upvotes: 4

Xella
Xella

Reputation: 1268

Maybe this is what you need: jsfiddle .

I've added new classes, so as not to overwrite the default bootstrap.

Upvotes: 3

Related Questions