在 Bootstrap 轮播中垂直居中文本 [英] Vertically center text in Bootstrap carousel

查看:26
本文介绍了在 Bootstrap 轮播中垂直居中文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Bootstrap 4 中创建带有水平和垂直居中文本的旋转木马时遇到问题.

我已经创建了带有轮播的 bootply,但文本就在左上角角落而不是屏幕中间.

<div class="carousel-item"><h1>文本 2</h1>

<div class="carousel-item"><h1>文本 3</h1>

'

解决方案

您可以使用 Bootstrap 4 实用程序类(不需要额外的 CSS)...

https://www.codeply.com/go/ORkdymGWzM

<div class="carousel-item"><div class="d-flex h-100 align-items-center justify-content-center"><h1>文本 2</h1>

<div class="carousel-item"><div class="d-flex h-100 align-items-center justify-content-center"><h1>文本 3</h1>

I have trouble creating a carousel in Bootstrap 4 with text centered both horizontally and vertically.

I have created the bootply with a carousel, but the text is just in the upper left corner instead of in the middle of the screen.

<div class="carousel slide" data-ride="carousel">
  <div class="carousel-inner">
    <div class="carousel-item active">
      <h1>Text 1</h1>
    </div>
    <div class="carousel-item">
      <h1>Text 2</h1>
    </div>
    <div class="carousel-item">
      <h1>Text 3</h1>
    </div>´
  </div>
</div>

解决方案

You can use the Bootstrap 4 utility classes (no additional CSS is needed)...

https://www.codeply.com/go/ORkdymGWzM

<div class="carousel slide" data-ride="carousel">
    <div class="carousel-inner text-center">
        <div class="carousel-item active">
            <div class="d-flex h-100 align-items-center justify-content-center">
                <h1>Text 1</h1>
            </div>
        </div>
        <div class="carousel-item">
            <div class="d-flex h-100 align-items-center justify-content-center">
                <h1>Text 2</h1>
            </div>
        </div>
        <div class="carousel-item">
            <div class="d-flex h-100 align-items-center justify-content-center">
                <h1>Text 3</h1>
            </div>
        </div>
    </div>
</div>

这篇关于在 Bootstrap 轮播中垂直居中文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆