cssbulma

cards with same size in columns


I face a similar problem like described here: I want to place 3-6 cards next to each other and I want them to be the same width & height. I tied adding is-flex option to the column, but this tampered with the widths of the columns (but did work for the height). Also I want to make sure the "order now" button stays on the bottom.

I packed everything in the code:

<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/1.0.1/css/bulma.min.css" rel="stylesheet" />

<div class="columns ml-1 mt-3">
  <div class="column is-3">
    <div class="card has-background-warning-light">
      <div class="card-header">
        <p class="has-text-right card-header-title is-centered is-uppercase">
          regular price
        </p>
      </div>
      <div class="card-image">
        <div class="has-background-warning">
          <div class="has-text-centered">
            <span class="is-size-1 has-text-weight-bold has-text-white">
                                    450 €
                                </span>

          </div>
        </div>
      </div>
      <div class="card-content">
        <div class="content">
          <p class="title is-3" style="display: flex;">
            standard price available for everyone
          </p>

          <button class="button is-dark is-fullwidth is-uppercase has-text-weight-bold">
                                order
                            </button>
        </div>
      </div>
    </div>
  </div>
  <div class="column is-3">
    <div class="card has-background-danger-light">
      <div class="card-header">
        <p class="has-text-right card-header-title is-centered is-uppercase">
          for early birds
        </p>
      </div>
      <div class="card-image">
        <div class="has-background-danger">
          <div class="has-text-centered">
            <span class="is-size-1 has-text-weight-bold has-text-white">
                                    350 €
                                </span>

          </div>
        </div>
      </div>
      <div class="card-content">
        <div class="content">
          <p class="title is-3" style="display: flex;">
            very long text that showas thet the items becomes mostly taller than the other ones.
          </p>

          <button class="button is-dark is-fullwidth is-uppercase has-text-weight-bold">
                                order
                            </button>
        </div>
      </div>
    </div>
  </div>

  <div class="column is-3">
    <div class="card has-background-info-light">
      <div class="card-header">
        <p class="has-text-right card-header-title is-centered is-uppercase">
          reduced
        </p>
      </div>
      <div class="card-image">
        <div class="has-background-info">
          <div class="has-text-centered">
            <span class="is-size-1 has-text-weight-bold has-text-white">
                                    250 €
                                </span>
          </div>
        </div>
      </div>
      <div class="card-content">

        <div class="content">
          <p class="title is-3" style="display: flex;">
            only until ...
          </p>

          <button class="button is-dark is-fullwidth is-uppercase has-text-weight-bold">
                                order
                            </button>
        </div>
      </div>
    </div>
  </div>

  <div class="column is-3">
    <div class="card">
      <div class="card-header has-background-primary-light">
        <p class="has-text-right card-header-title is-centered is-uppercase">
          green price
        </p>
      </div>
      <div class="card-image">
        <div class="has-background-primary">
          <div class="has-text-centered">
            <span class="is-size-1 has-text-weight-bold has-text-white">
                                    180 €
                                </span>

          </div>
        </div>
      </div>
      <div class="card-content">

        <div class="content">
          <p class="title is-3">
            the reason
          </p>

          <button class="button is-dark is-fullwidth is-uppercase has-text-weight-bold mt-auto">
                                order
                            </button>
        </div>
      </div>
    </div>
  </div>
</div>

What I have: enter image description here

How can I achieve to have all cards the same height & width, with the order button on the bottom? I found a workaround with defining a min-height: 10rem; but I don't want to work with a fixed size if possible.


Solution

  • I've added some css, hope it's what you're looking for:

    .column {
      display: flex!important;
      flex-direction: column;
    }
    
    .card,
    .card-content,
    .card-content .content {
      flex: auto;
      display: flex;
      flex-direction: column;
    }
    
    .card .button {
      margin-top:auto;
    }
    <link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/1.0.1/css/bulma.min.css" rel="stylesheet"/>
    
    <div class="columns ml-1 mt-3">
      <div class="column is-3">
        <div class="card has-background-warning-light">
          <div class="card-header">
            <p class="has-text-right card-header-title is-centered is-uppercase">
              regular price
            </p>
          </div>
          <div class="card-image">
            <div class="has-background-warning">
              <div class="has-text-centered">
                <span class="is-size-1 has-text-weight-bold has-text-white">
                                        450 €
                                    </span>
    
              </div>
            </div>
          </div>
          <div class="card-content">
            <div class="content">
              <p class="title is-3" style="display: flex;">
                standard price available for everyone
              </p>
    
              <button class="button is-dark is-fullwidth is-uppercase has-text-weight-bold">
                                    order
                                </button>
            </div>
          </div>
        </div>
      </div>
      <div class="column is-3">
        <div class="card has-background-danger-light">
          <div class="card-header">
            <p class="has-text-right card-header-title is-centered is-uppercase">
              for early birds
            </p>
          </div>
          <div class="card-image">
            <div class="has-background-danger">
              <div class="has-text-centered">
                <span class="is-size-1 has-text-weight-bold has-text-white">
                                        350 €
                                    </span>
    
              </div>
            </div>
          </div>
          <div class="card-content">
            <div class="content">
              <p class="title is-3" style="display: flex;">
                very long text that showas thet the items becomes mostly taller than the other ones.
              </p>
    
              <button class="button is-dark is-fullwidth is-uppercase has-text-weight-bold">
                                    order
                                </button>
            </div>
          </div>
        </div>
      </div>
    
      <div class="column is-3">
        <div class="card has-background-info-light">
          <div class="card-header">
            <p class="has-text-right card-header-title is-centered is-uppercase">
              reduced
            </p>
          </div>
          <div class="card-image">
            <div class="has-background-info">
              <div class="has-text-centered">
                <span class="is-size-1 has-text-weight-bold has-text-white">
                                        250 €
                                    </span>
              </div>
            </div>
          </div>
          <div class="card-content">
    
            <div class="content">
              <p class="title is-3" style="display: flex;">
                only until ...
              </p>
    
              <button class="button is-dark is-fullwidth is-uppercase has-text-weight-bold">
                                    order
                                </button>
            </div>
          </div>
        </div>
      </div>
    
      <div class="column is-3">
        <div class="card">
          <div class="card-header has-background-primary-light">
            <p class="has-text-right card-header-title is-centered is-uppercase">
              green price
            </p>
          </div>
          <div class="card-image">
            <div class="has-background-primary">
              <div class="has-text-centered">
                <span class="is-size-1 has-text-weight-bold has-text-white">
                                        180 €
                                    </span>
    
              </div>
            </div>
          </div>
          <div class="card-content">
    
            <div class="content">
              <p class="title is-3">
                the reason
              </p>
    
              <button class="button is-dark is-fullwidth is-uppercase has-text-weight-bold mt-auto">
                                    order
                                </button>
            </div>
          </div>
        </div>
      </div>
    </div>