Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Two forms submit button stay beside each other

<form class="listing_form" action="{% url 'listing' listing.id  %}" method="post">
            {% csrf_token %}
            {{ form }}
            <input class="btn btn-primary" type="submit" value="Place Bid">
</form>
<form class="listing_form_close" action="{% url 'close' listing.id %}" method="post">
            {% csrf_token %}
            {% if listing.listedBy.username == request.user.username %}
            <input class="btn btn-danger" type="submit" value="Close Bid">
            {% endif %}
</form>

In this code, two submit buttons are stays vertically.

enter image description here

I need styling same below:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

As I have tried:

.listing_form [type="submit"] {
    margin-bottom: 20px;
    display: inline;
  }
  .listing_form_close [type="submit"] {
    display: inline;
  }

In my css code, but not works!

Appreciated.

>Solution :

The problem in your CSS code is, that you add display: inline to the input element, which is inside a form element. In this case, all buttons of the type submit inside a form would be inline.

What you actually want to do is to add the display: inline attribute to your form. So that the two forms which including the buttons are next to each other.

.listing_form {
  display: inline;
}
<form class="listing_form" action="URL" method="post">
  <input class="btn btn-primary" type="submit" value="Place Bid">
</form>
<form class="listing_form" action="URL" method="post">
  <input class="btn btn-danger" type="submit" value="Close Bid">
</form>

Note: I changed the form class of the second form from listing_form_close to listing_form.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading