skip to Main Content

Using bulma makes it easy to position text – usually. I was not able to place the card-header attribute centered.

My Try:

<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/1.0.1/css/bulma.min.css" rel="stylesheet"/>
<div class="columns mt-3">
        <div class="column is-3 ml-3" style="display: flex;">
            <div class="card has-background-warning-light">
                <div class="card-header">
                    <p class="has-text-right is-size-5 is-uppercase has-text-centered">
                        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">
                                $ 999
                            </span>

                        </div>
                    </div>
                    <!-- <figure class="image is-3by1">
                        <img src="https://bulma.io/assets/images/placeholders/1280x960.png" alt="Placeholder"/>
                    </figure> -->
                </div>
                <div class="card-content">
                    <div class="media">
                        <!-- <div class="media-left">
                            <figure class="image is-64x64">
                                {{ teacher.country.show_flag }}
                            </figure>
                        </div> -->
                        <div class="media-content">
                            <p class="title is-3" style="display: flex;">
                                standard price available for everyone
                            </p>
                            <p class="subtitle is-6 mt-1">
                                regular price
                            </p>
                        </div>
                    </div>
                    <div class="content has-text-centered">
                        <button class="button is-dark">
                          BUY  
                        </button>
                    </div>
                </div>
            </div>
        </div>

Why is my has-text-centered not applied at the card-header but everywhere else?

2

Answers


  1. <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Bulma Card Header Centered</title>
      <link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/1.0.1/css/bulma.min.css" rel="stylesheet"/>
      <style>
        .card-header {
          justify-content: center;
        }
      </style>
    </head>
    <body>
      <div class="columns mt-3">
        <div class="column is-3 ml-3">
          <div class="card has-background-warning-light">
            <div class="card-header">
              <p class="is-size-5 is-uppercase has-text-centered">
                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">
                    $ 999
                  </span>
                </div>
              </div>
            </div>
            <div class="card-content">
              <div class="media">
                <div class="media-content">
                  <p class="title is-3">
                    standard price available for everyone
                  </p>
                  <p class="subtitle is-6 mt-1">
                    regular price
                  </p>
                </div>
              </div>
              <div class="content has-text-centered">
                <button class="button is-dark">
                  BUY
                </button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </body>
    </html>
    Login or Signup to reply.
  2. MrUpsidown’s comment was helpful. In Bulma, you can center elements by using a built-in utility class. Center text or elements within a container with the .is-centered class.

    For your card header:

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <link href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css" rel="stylesheet">
    </head>
    <body>
      <div class="columns mt-3">
        <div class="column is-3 ml-3">
          <div class="card has-background-warning-light">
            <div class="card-header">
              <p class="card-header-title is-centered">Centered Header</p>
            </div>
          </div>
        </div>
      </div>
    </body>
    </html>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search