<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.
I need styling same below:
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.
2
Answers
The problem in your CSS code is, that you add
display: inline
to theinput
element, which is inside aform
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 yourform
. So that the two forms which including the buttons are next to each other.Note: I changed the form class of the second form from
listing_form_close
tolisting_form
.Based on your code, you have incorrectly specified the CSS-selector for buttons.
You’re CSS-selectors have spaces between class name
.listing_form
and attribute selector[type="submit"]
, CSS understands that like.listing_form
is a parent[type="submit"]
element.Also, I recommend the use
display: incline-block
Here is more information about CSS-selectors:
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors
Good luck!