Reputation: 511
I have a table, within which I want to put a drop-down button. I cannot center the button, and I have tried many things. Is there a way to do this?
<table class = "table table-hover table-condensed">
<tr>
<th class = "text-center">
Test
</th>
</tr>
<tr>
<td>
<div class="col-md-3 text-left">
<div class="button-group">
<button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-cog"></span> <span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="#" class="small" data-value="Option1" tabIndex="-1"><input type="checkbox"/> Option1</a></li>
<li><a href="#" class="small" data-value="Option2" tabIndex="-1"><input type="checkbox"/> Option2</a></li>
</ul>
</div>
</div>
</td>
</tr>
</table>
Upvotes: 0
Views: 79
Reputation: 2302
Put the class "text center" in this div. Here is codepen to see:
<div class="button-group text-center">
Also take take away col-md-3 and text-left from the containing div's class
Upvotes: 2
Reputation: 9642
Just remove col-md-3 text-left
and add text-center
on parent div of button. check updated snippet below...
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="http://code.jquery.com/jquery-3.1.1.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<table class = "table table-hover table-condensed">
<tr>
<th class = "text-center">
Test
</th>
</tr>
<tr>
<td>
<div class="text-center">
<div class="button-group">
<button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-cog"></span> <span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="#" class="small" data-value="Option1" tabIndex="-1"><input type="checkbox"/> Option1</a></li>
<li><a href="#" class="small" data-value="Option2" tabIndex="-1"><input type="checkbox"/> Option2</a></li>
</ul>
</div>
</div>
</td>
</tr>
</table>
Upvotes: 2