Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Align buttons side by side - bootstrap 3

Take a look at the below example.

Link to Bootply

I want the <a> tag to be besides Button 2.

like image 892
user2281858 Avatar asked Jun 14 '14 12:06

user2281858


People also ask

How do I place a button side by side in Bootstrap?

You can use an out div with a class btn-group . This helps to align the buttons horizontally. Using col-md-6 for each button div can make the buttons missaligned with unwanted space in between.

How can I put two buttons on the same line in Bootstrap?

Use the . btn-group class in Bootstrap to group buttons on a single like.

How do you align two buttons in one line?

If you have multiple buttons that should sit side-by-side on the same line, add the data-inline="true" attribute to each button. This will style the buttons to be the width of their content and float the buttons so they sit on the same line.

How do I move the button to the right side in Bootstrap?

Bootstrap allows us to align elements by using the utility class float. As we want to align the button to the right side of the text box, we have to use the float-right class.


1 Answers

Bootstrap uses 12 column grid. Right now two buttons take the whole available space (both 6-column width) leaving no space for the third. You can layout your buttons as 5+5+2 columns. For example:

<div class="col-md-6 col-md-offset-2">
    <button type="submit" class="btn btn-default btn-md col-md-5">Button 1</button>
    <button type="reset" class="btn btn-default btn-md col-md-5">Button 2</button>
    <a href="#" class="btn btn-default btn-md col-md-2"><span class="glyphicon glyphicon-search"></span></a>
</div>

Demo: http://www.bootply.com/RAqyEiTp1i

You want to place the third button outside the row container, you can position it absolutely relatively to the col group:

<a href="#" class="btn btn-default btn-beside"><span class="glyphicon glyphicon-search"></span></a>

CSS:

.btn-beside {
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: -10px;
}

Demo: http://www.bootply.com/5n3y1uZDng

like image 165
dfsq Avatar answered Sep 27 '22 03:09

dfsq