Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap pull right buttons in list hanging out

I have the following code:

<div class="container">
    <ul class="list-group">
        <li class="list-group-item">
            userA <span class="label label-default">admin</span>
            <span class="pull-right button-group">
                <a href="/admin/userA" class="btn btn-primary"><span class="glyphicon glyphicon-edit"></span> Edit</a> 
                <button type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete</button>
            </span>
        </li>
    </ul>
</div>

enter image description here

I would like to make the box bigger so the buttons fit within, whilst keeping the text/label vertically centered. Alternatively, moving the buttons up to be within the box would work. I'm using bootstrap 3.2. Any advice welcome. Thanks.

like image 205
Benjamin Avatar asked Aug 14 '14 19:08

Benjamin


2 Answers

The fix is simple, just add the clearfix to the element containing the floated items:

    <li class="list-group-item clearfix">

DEMO:http://jsbin.com/yazoj/1/edit

And

.list-group {line-height:30px}
like image 71
Christina Avatar answered Nov 14 '22 09:11

Christina


Here is jsfiddle

Code:

<div class="container">
  <ul class="list-group">
    <li class="list-group-item clearfix">
      <!-- wrapped the text and label in a span -->
      <span style="position:absolute; top:30%;">userA <span class="label label-default">admin</span></span>
      <span class="pull-right button-group">
        <a href="/admin/userA" class="btn btn-primary"><span class="glyphicon glyphicon-edit"></span> Edit</a> 
        <button type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete</button>
      </span>
    </li>
  </ul>
</div>

You may want to move the inline style to css file.

like image 41
Bongs Avatar answered Nov 14 '22 08:11

Bongs