0

I have a bootstrap 4 card with a button at the end that is a form button with a POST method and url attached to it. How can I align this button to the bottom of the card? Here is my current code, which, if used with a non-form button, would work just fine. You can see that I have d-flex and flex-column in the card-body as well as mt-auto on the button as suggested by Bootstrap - align button to the bottom of card

div class="container">
  <div class="card-deck mb-3 mt-4 text-center">

    {% for object in object_list %}

    <div class="card mb-4 box-shadow">
      <div class="card-header">
        <h4 class="my-0 font-weight-normal">Stuff</h4>
      </div>
      <div class="card-body d-flex flex-column">
        {% if Stuff == 'Stuff' %}
        <h3 class="card-title pricing-card-title">Stuff</h3>
        {% else %}
        <h3 class="card-title pricing-card-title">Stuff</h3>
        {% endif %}
        {% if Stuff != 'Stuff' %}
        <small>Stuff</small>
        <small>{{ Stuff }} Stuff</small>
        {% endif %}
        {% if Stuff != 'Stuff' %}
        <ul class="list-unstyled mt-3 mb-4">
          <li>Stuff</li>
          <li>Stuff</li>
          <li>Stuff</li>
          <li>Stuff</li>
          <li><strong>Stuff</strong></li>
          <li>Stuff</li>
          {% if Stuff == 'Stuff' %}
          <li>Stuff</li>
          {% endif %}
        </ul>
        {% else %}
        <ul class="list-unstyled mt-3 mb-4">
          <li>Stuff</li>
          <li>Stuff</li>
          <li>Stuff</li>
          <li>Stuff</li>
        </ul>
        {% endif %}
        <form method="POST" action="{% url 'Stuff' %}">
          {% csrf_token %}
          <div class="form-group">
            <div class="row d-flex justify-content-center">
              <div class="col-5">
                <button type="submit" class="btn btn-info btn-md btn-block login-button mt-auto">Stuff</button>
              </div>
            </div>
          </div>
          <!-- <button class="btn btn-warning">Stuff</button> -->
          <input type="hidden" name="Stuff" value="{{ Stuff }}">
        </form>


      </div>

    </div>
    {% endfor %}
  </div>


</div>
Fiboniz
  • 37
  • 6

2 Answers2

0

I hope that I am understanding you the right way, but what if you add this to the CSS:

.card-body{
padding-bottom:  0px;
}

The button will be closer to the bottom of the card.

Yuvalkon
  • 1
  • 2
  • It's honestly not about how close the button is to the bottom. Rather, that they are all aligned at the same point at the bottom as in the question: https://stackoverflow.com/questions/48406628/bootstrap-align-button-to-the-bottom-of-card – Fiboniz May 07 '20 at 13:34
0

Solved it by using class="mt-auto" on the form section. This question: bootstrap card buttons and input text aligned bottom says that anything under the mt-auto gets bottom-aligned.

Fiboniz
  • 37
  • 6