Bootstrap 4, How do I center-align a button?

2020-05-12 05:01发布

<div class="container">
  <div class="row">
    <div class="col-xs-12 col-sm-12 col-md-8">
      <div v-for="job in job">
        <div class="text-center">
          <h1>{{ job.job_title }}</h1>
          <p><strong>Google Inc. </strong> - {{ job.location }}</p>
          <h2><u>Job Description</u></h2>
        </div>
        <p v-html="desc"></p>
        <p class="text-center">Posted: {{ formatDate(job.date_created) }}</p>
        <button v-on:click="applyResume()" id="apply-btn" class="btn btn-primary">{{ buttonText }}</button>
      </div>
    </div>
    <div class="hidden-sm-down col-md-4"></div>
  </div>
</div>

Can't figure out how to center this button. In BS 3 I would just use center-block but that's not an option in BS4. Any advice?

8条回答
虎瘦雄心在
2楼-- · 2020-05-12 05:19

you can also just wrap with an H class or P class with a text-center attribute

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2020-05-12 05:28

Here is the full HTML that I use to center by button in Bootsrap form after closing form-group:

<div class="form-row text-center">
    <div class="col-12">
        <button type="submit" class="btn btn-primary">Submit</button>
    </div>
 </div>
查看更多
登录 后发表回答