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
  • 783
  • 3
  • 12
  • 23

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
  • 39,971
  • 43
  • 126
  • 190
0

Just use float:left; on the buttons

Css:

button {float:left;}

DEMO

Carl0s1z
  • 4,683
  • 7
  • 32
  • 47
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
  • 14,110
  • 21
  • 98
  • 160