bbe*_*t36 57 css twitter-bootstrap bootstrap-4
<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>
Run Code Online (Sandbox Code Playgroud)
无法弄清楚如何居中这个按钮.在BS 3中,我只使用中心块,但这不是BS4中的选项.有什么建议?
And*_*hiu 117
在Bootstrap 4中,您应该使用text-center
该类来对齐内联块.
注意:text-align:center;
无论您使用的Bootstrap版本如何,在应用于父元素的自定义类中定义都将起作用.而这正是.text-center
适用的.
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<div class="container">
<div class="row">
<div class="col text-center">
<button class="btn btn-default">Centered button</button>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
Bob*_*kes 41
使用 bootstrap 4 实用程序,您可以通过将水平边距设置为“自动”来水平居中元素本身。
要将水平边距设置为自动,您可以使用mx-auto
. 所述m
指余量和x
将参考x轴(左+右)和auto
将参考设定。因此,这会将左边距和右边距设置为“自动”设置。浏览器将平均计算边距并使元素居中。该设置仅适用于块元素,因此需要添加 display:block 并且使用引导实用程序,这是由d-block
.
<button type="submit" class="btn btn-primary mx-auto d-block">Submit</button>
Run Code Online (Sandbox Code Playgroud)
您可以根据此答案浏览器支持边距:自动考虑所有浏览器完全支持自动边距设置,因此可以安全使用。
bootstrap 4 类text-center
也是一个很好的解决方案,但是它需要一个父包装元素。使用自动边距的好处是它可以直接在按钮元素本身上完成。
小智 21
这是完成的HTML,我在关闭表单组后用Bootsrap表单按钮按中心:
<div class="form-row text-center">
<div class="col-12">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
小智 16
用bootstrap试试
<div class="row justify-content-center">
<button type="submit" class="btn btn-primary">btnText</button>
</div>
Run Code Online (Sandbox Code Playgroud)
https://getbootstrap.com/docs/4.1/layout/grid/#variable-width-content
归档时间: |
|
查看次数: |
142074 次 |
最近记录: |