在小型设备上测试时,轮播字幕显示不正确。请检查我添加的图像。

Screenshot of large device

Screenshot of small device

<div id="carouselExampleCaptions" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
  <li data-target="#carouselExampleCaptions" data-slide-to="0" class="active"></li>
  <li data-target="#carouselExampleCaptions" data-slide-to="1"></li>
  <li data-target="#carouselExampleCaptions" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
  <div class="carousel-item active">
    <img src="image/ramya-carusel.png" class="d-block w-100" alt="Field irrigation">
    <div class="carousel-caption  col-md-5 col-sm-12 col-8">
      <h1>Experience Real Life Quality in Offset and Digital Printing.</h1>
        <button type="button" class="btn btn-light">Learn more</button>
    </div>
  </div>
  <div class="carousel-item">
        <img src="image/ramya-carusel.png" class="d-block w-100" alt="Field irrigation">
    <div class="carousel-caption col-md-5 col-sm-12 col-8">
      <h1>Experience Real Life Quality
        in Offset and Digital Printing.</h1>
        <button type="button" class="btn btn-light">Learn more</button>
    </div>
  </div>
  <div class="carousel-item">
        <img src="image/ramya-carusel.png" class="d-block w-100" alt="Field irrigation">
    <div class="carousel-caption col-md-5 col-sm-12 col-8">
      <h1>Experience Real Life Quality
        in Offset and Digital Printing.</h1>
        <button type="button" class="btn btn-light">Learn more</button>
    </div>
  </div>
</div>
<a class="carousel-control-prev" href="#carouselExampleCaptions" 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="#carouselExampleCaptions" role="button" data-slide="next">
  <span class="carousel-control-next-icon" aria-hidden="true"></span>
  <span class="sr-only">Next</span>
</a>

最佳答案

您可以覆盖.carousel-caption CSS规则来调整元素的大小,以使其清晰可见。

@media screen and (max-width: 768px)
     {    .carousel-caption {
          bottom: 50px !important;
          }
          .carousel-caption h1 {
          font-size : 20px !important;
          }
     }


对于最大宽度为768px的设备,上述CSS会将h1元素的字体大小更改为20px。 CSS类.carousel-caption的位置是绝对的,因此,如果不合适的话,请将bottom增大到更高。

关于javascript - 如何使轮播字幕具有响应性?我在说明框中添加了图片和代码,请仔细查看,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59509674/

10-11 14:09