引导轮播字幕不响应? (HTML,CSS)

时间:2019-03-16 15:52:59

标签: html css responsive caption h3

我正在尝试制作一个响应式轮播,其标题包含一个p标签和一个h3标签。看起来不错,但是每当我调整窗口大小以查看在移动设备上的外观时,h3和p标签几乎都无法调整。

如何使字幕具有响应性?我将在下面发布代码,以便您可以尝试一下。我的html和CSS。

.carousel-caption {
    width: 50%;
    top: 20%;
    text-align: left;
}

.carousel-caption h3{
    font-weight: bold;
    font-size: 4em;
    text-align:left;
}

.carousel-caption p{
    font-size: 30px;
    text-align:left;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>

<section class="jsslider" id="home">
  <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="3"></li>
      <li data-target="#carouselExampleIndicators" data-slide-to="4"></li>
      <li data-target="#carouselExampleIndicators" data-slide-to="5"></li>
    </ol>
    <div class="carousel-inner">
      <div class="carousel-item active"> <img class="d-block w-100" src="fotos/Slider1.jpg" alt="ersteSlide">
        <div class="carousel-caption">
          <h3>So groß wie ein halber Fußballfeld.
          </h3>
          <p>Große Waldbrände entsprechen ungefähr einer größe von einem halben Fußballfeld. </p>
        </div>
      </div>
      <div class="carousel-item"> <img class="d-block w-100" src="fotos/slider2.jpg" alt="zweiteSlide">
                <div class="carousel-caption">
          <h3>So groß wie ein halber Fußballfeld.
          </h3>
          <p>Große Waldbrände entsprechen ungefähr einer größe von einem halben Fußballfeld. </p>
        </div>
      </div>
      <div class="carousel-item"> 
       <img class="d-block w-100" src="fotos/slider3.jpg" alt="dritteSlide">
                <div class="carousel-caption">
          <h3>So groß wie ein halber Fußballfeld.
          </h3>
          <p>Große Waldbrände entsprechen ungefähr einer größe von einem halben Fußballfeld. </p>
        </div>
      </div>
      <div class="carousel-item"> <img class="d-block w-100" src="fotos/slider4.jpg" alt="vierteSlide">
                <div class="carousel-caption">
          <h3>So groß wie ein halber Fußballfeld.
          </h3>
          <p>Große Waldbrände entsprechen ungefähr einer größe von einem halben Fußballfeld. </p>
        </div>
      </div>
      <div class="carousel-item"> <img class="d-block w-100" src="fotos/slider5.jpg" alt="fuenfteSlide">
                <div class="carousel-caption">
          <h3>So groß wie ein halber Fußballfeld.
          </h3>
          <p>Große Waldbrände entsprechen ungefähr einer größe von einem halben Fußballfeld. </p>
        </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>
</section>

1 个答案:

答案 0 :(得分:0)

您需要在引导程序的断点上设置字体大小。示例:

.carousel-caption h3 {
    font-weight: bold;
    font-size: 1.2em; /* small size since this is the default in Bootstrap */
    text-align:left;
}

.carousel-caption p {
    font-size: 1em; /* small size since this is the default in Bootstrap */
    text-align:left;
}
@media (min-width: 576px) { // Small devices (landscape phones, 576px and up)
  .carousel-caption h3 { font-size: 1.3em;}
  .carousel-caption p {font-size: 1.1em;}  
}
@media (min-width: 768px) {// Medium devices (tablets, 768px and up)
  .carousel-caption h3 { font-size: 1.4em;}
  .carousel-caption p {font-size: 1.2em;}  
}
@media (min-width: 992px) { // Large devices (desktops, 992px and up)
  .carousel-caption h3 { font-size: 1.5em;}
  .carousel-caption p {font-size: 1.3em;}  
}
@media (min-width: 1200px) { // Extra large devices (large desktops, 1200px and up)
  .carousel-caption h3 { font-size: 1.6em;}
  .carousel-caption p {font-size: 1.4em;}  
}

当然,这只是一个例子。看看here,然后 希望有帮助。