首页 > 解决方案 > 我需要使轮播中的文本具有响应性

问题描述

我使用了 bootstrap 4 类和媒体查询,但是当我在手机上查找网站时,文本消失了。` -----任何文本 ------- -----任何文本 ------ - ---任何文字---

        </div>
    </div>
    <div class="carousel-item">
        <img class="d-block w-100" src=" img2.png" alt="Second slide" style="height: auto">
        <div class="carousel-caption d-none d-md-block n28">
            <h1 class="n26 animated bounceInRight display-2" style="animation-delay: 0.5s">-----any text -------</h1>
            <h3 class="animated bounceInLeft" style="animation-delay: 0.5s">-----any text -------</h3>
        </div>
    </div>
    <div class="carousel-item">
        <img class="d-block w-100" src="img3.png" alt="Third slide" style="height: auto">
        <div class="carousel-caption d-none d-md-block n28">
            <h1 class="n26 animated bounceInRight display-2" style="animation-delay: 0.5s">-----any text -------</h1>
            <h3 class="animated bounceInLeft" style="animation-delay: 0.5s">-----any text -------</h3>
        </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>

  .carousel-caption{
position: absolute;
top: 30%;
transform: translateY(-50);}
 .carousel-caption h1{
font-size: 500%;}
 .carousel-caption h3{
font-size: 110%;
font-family: "Poppins", sans-serif;}

标签: htmlcss

解决方案


我做了这个并且反应灵敏。请检查一下。谢谢

@media only screen and (max-width: 767px) {

.carousel-caption { display:none;}

}
<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">
    <div class="carousel-item active">
      <img class="d-block w-100" src="https://cruxnow.com/wp-content/uploads/2019/09/Natural-cemetery-Natuurbegraafplaats-Koningsakker-1024x576.jpg" alt="First slide">
      <div class="carousel-caption d-md-block n28">
            <h1 class="n26 animated bounceInRight display-2" style="animation-delay: 0.5s">-----any text -------</h1>
            <h3 class="animated bounceInLeft" style="animation-delay: 0.5s">-----any text -------</h3>
        </div>
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="https://cruxnow.com/wp-content/uploads/2019/09/Natural-cemetery-Natuurbegraafplaats-Koningsakker-1024x576.jpg" alt="Second slide">
      <div class="carousel-caption d-md-block n28">
            <h1 class="n26 animated bounceInRight display-2" style="animation-delay: 0.5s">-----any text -------</h1>
            <h3 class="animated bounceInLeft" style="animation-delay: 0.5s">-----any text -------</h3>
        </div>
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="https://cruxnow.com/wp-content/uploads/2019/09/Natural-cemetery-Natuurbegraafplaats-Koningsakker-1024x576.jpg" alt="Third slide">
      <div class="carousel-caption d-md-block n28">
            <h1 class="n26 animated bounceInRight display-2" style="animation-delay: 0.5s">-----any text -------</h1>
            <h3 class="animated bounceInLeft" style="animation-delay: 0.5s">-----any text -------</h3>
        </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>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>


推荐阅读