【问题标题】:Modify the height of Bootstrap Carousel control?修改 Bootstrap Carousel 控件的高度?
【发布时间】:2020-07-05 17:33:14
【问题描述】:

下图的蓝色部分显示了引导轮播的触发区域。我从bootstrap doc截取了截图。

我想修改触发区域的高度(例如,从轮播高度的 100% 到 50%)。我可以知道如何修改它吗?

提前致谢

【问题讨论】:

    标签: css twitter-bootstrap bootstrap-4 carousel


    【解决方案1】:

    要解决这个问题,只需在 CSS 中修改 .carousel-control-prev.carousel-control-prev 的属性即可。

    .carousel-control-prev,
    .carousel-control-next {
      height: 25%;
      top: 37.5%;
    };
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
    
    <body>
      <div class="container">
        <div class="row">
          <div class="col">
            <div id="carouselExampleIndicators" class="carousel slide my-4" 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">
                <div class="carousel-item active">
                  <img class="d-block img-fluid" src="http://placehold.it/900x350" alt="First slide">
                </div>
                <div class="carousel-item">
                  <img class="d-block img-fluid" src="http://placehold.it/900x350" alt="Second slide">
                </div>
                <div class="carousel-item">
                  <img class="d-block img-fluid" src="http://placehold.it/900x350" alt="Third slide">
                </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>
          </div>
        </div>
      </div>
    </body>

    我不知道为什么 top 属性无法在演示中覆盖。但它适用于我的项目。

    【讨论】:

      猜你喜欢
      • 2018-12-30
      • 2015-12-28
      • 2022-01-21
      • 1970-01-01
      • 2015-02-25
      • 2019-09-21
      • 2018-06-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多