<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?
With the use of the bootstrap 4 utilities you could horizontally center an element itself by setting the horizontal margins to 'auto'.
To set the horizontal margins to auto you can use
mx-auto
. Them
refers to margin and thex
will refer to the x-axis (left+right) andauto
will refer to the setting. So this will set the left margin and the right margin to the 'auto' setting. Browsers will calculate the margin equally and center the element. The setting will only work on block elements so the display:block needs to be added and with the bootstrap utilities this is done byd-block
.You can consider all browsers to fully support auto margin settings according to this answer Browser support for margin: auto so it's safe to use.
The bootstrap 4 class
text-center
is also a very good solution, however it needs a parent wrapper element. The benefit of using auto margin is that it can be done directly on the button element itself.Use
text-center
class in the parent container for Bootstrap 4What worked for me was (adapt "css/style.css" to your css path):
Head HTML:
Body HTML:
Css:
for a button in a collapsed navbar nothing above worked for me so in my css file i did.....
and it worked!!
In Bootstrap 4 you should use the
text-center
class to align inline-blocks.NOTE:
text-align:center;
defined in a custom class you apply to your parent element will work regardless of the Bootstrap version you are using. And that's exactly what.text-center
applies.Try this with bootstrap
CODE:
LINK:
https://getbootstrap.com/docs/4.1/layout/grid/#variable-width-content