0

I have 2 buttons and I want them in the same line.

The buttons come one below the other because one is inside an <a> element and one is inside a form

Here is the code

<a href="update/"><button class="btn btn-default">Update Contact</button></a>
<form action="" method="post">
{% csrf_token %}
    <button type="submit" class="btn btn-default">Delete Contact</button>
</form>

How can I get them in the same line?

Fiddle - http://www.bootply.com/114827

Unknown Coder
  • 723
  • 3
  • 11
  • 22

3 Answers3

1

It's very easy you just need to float them or put them as inline or inline block, or whatever element that contains them (that would be cleaner):

http://www.bootply.com/114841

In this particular case:

a, form{
  float: left;
}

or

a, form{
  display: inline-block;
}

Read about the differences here: https://stackoverflow.com/a/11823622/463065

Community
  • 1
  • 1
Trufa
  • 38,078
  • 41
  • 121
  • 186
0

Just use float:left; on the buttons

Css:

button {float:left;}

DEMO

C Travel
  • 4,673
  • 7
  • 31
  • 46
0

Use an "inline" CSS class:

HTML:

<a href="update/">
  <button class="btn btn-default">Update Contact</button>
</a>
<form action="" method="post" class="inline">
  <button type="submit" class="btn btn-default">Delete Contact</button>
</form>

CSS:

.inline {
   display: inline-block;
 }

Example:
http://www.bootply.com/114837

Fez Vrasta
  • 12,758
  • 19
  • 86
  • 149