【问题标题】:Bootstrap 4 Carousel with solid color in background and Image on right and text on leftBootstrap 4 Carousel,背景为纯色,右侧为图像,左侧为文本
【发布时间】:2020-02-29 15:12:25
【问题描述】:

如果我问的问题很愚蠢,请原谅我,但我需要创建一个以纯色为背景的整页滑块,左侧为一些文本,右侧为图像。像Google's Gmail Page 这样的东西。 目前我想要的结果是

我用过 Bootstrap 4 的 Carousel

我对其稍作修改,使其背景为灰色,与 Google 图像中的一样。现在我希望文本左对齐并在右侧有一个响应式自动调整大小的图像(或者即使我只能在文本顶部调整一个图像),这在移动设备上查看时也是响应式的。像

.

我正在使用this fiddle,我已将代码修改为

<div class="carousel-item" style="background-color: #eff0f1">
        <div class="carousel-caption d-none d-md-block">
          <h2 class="display-4">First Slide</h2>
          <p class="lead">This is a description for the first slide.</p>
        </div>
      </div>

<style>
    .carousel-item {
        background-color: #eeeeee; /*Solid grey background*/
        }
    .carousel-caption {
        color: black;
        }
</style>

【问题讨论】:

    标签: html css twitter-bootstrap responsive-design carousel


    【解决方案1】:

    从 carousel-caption 中删除 d-none 类并尝试这种方式:

    .carousel-item {
      height: 100vh;
      min-height: 350px;
      background: no-repeat center center scroll;
      -webkit-background-size: cover;
      -moz-background-size: cover;
      -o-background-size: cover;
      background-size: cover;
    }
    .text_part{
    	display: none;
    }
    @media (max-width: 575px){
    	.text_part{
    	display: block;
    }
    .left_part{
    	display: none;
    }
    }
      <section class="text_part">
        <div class="text">
         <h2 >your text</h2>
       </div>
     </section>
    
     <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
      <ol class="carousel-indicators">
        <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
        <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
        <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
      </ol>
      <div class="carousel-inner" role="listbox">
        <!-- Slide One - Set the background image for this slide in the line below -->
        <div class="carousel-item active" style="background-color: gray">
          <div class="carousel-caption  d-md-block">
            <div class="row">
              <div class="col-md-6 left_part">
                your text
              </div>
              <div class="col-md-6 col-sm-12">
               img
              </div>
            </div>
          </div>
        </div>
        <!-- Slide Two - Set the background image for this slide in the line below -->
        <div class="carousel-item" style="background-color: pink">
          <div class="carousel-caption  d-md-block">
            <div class="row">
              <div class="col-md-6 left_part">
                your text
              </div>
              <div class="col-md-6 col-sm-12">
               img
              </div>
            </div>
          </div>
        </div>
        <!-- Slide Three - Set the background image for this slide in the line below -->
        <div class="carousel-item" style="background-color: green">
         <div class="carousel-caption  d-md-block">
            <div class="row">
              <div class="col-md-6 left_part">
                your text
              </div>
              <div class="col-md-6 col-sm-12">
               img
              </div>
            </div>
          </div>
        </div>
      </div>
      <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
      </a>
      <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
      </a>
    </div>

    【讨论】:

      猜你喜欢
      • 2013-11-13
      • 2018-11-22
      • 1970-01-01
      • 1970-01-01
      • 2021-02-17
      • 1970-01-01
      • 1970-01-01
      • 2013-09-11
      • 2016-07-11
      相关资源
      最近更新 更多