【问题标题】:How to change carousel image slider arrows color only on the second slide?如何仅在第二张幻灯片上更改轮播图像滑块箭头颜色?
【发布时间】:2019-05-21 02:36:44
【问题描述】:

如何仅在第二张图像幻灯片上更改轮播图像滑块指示器箭头的颜色??? 在第一张幻灯片上,我想要黑色,但是当图像滑动到第二张幻灯片时,我想将指示器设置为白色。 这可能吗??? 我试图在第二张幻灯片上创建 id 标签,但没有帮助,CSS 专家知道如何做到这一点??? 最大的问题是我不能在 CSS 中只定位第二个幻灯片轮播图标,我不知道该怎么做。

我想定位 CSS 中的第二个图像滑块箭头图标,将箭头颜色设置为白色。 carousel-control-next, .carousel-control-prev

这是 HTML 代码,这是轮播图像滑块示例:

<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="1.jpg"   alt="First slide">
      <div class="carousel-caption">
      <h2 id="fadeuptext" class='animated fadeInUp' style="animation-delay: 1s">Hello</h2>
      <h2 id="fadelefttext" class='animated fadeInLeft' style="animation-delay: 2s">World</h2>

      </div>
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="2.jpg" style="height:797px;"   alt="Second slide">
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="3.jpg" style="height:797px;"   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>

【问题讨论】:

  • 您是否需要这样做,因为您看不到第二张幻灯片上的指标?
  • 是的,图片我用的太暗了,箭头指示是黑色的。所以我想换成白色。
  • 您能否编辑图像,使其同时显示在浅色和深色背景上?例如添加一些阴影/发光来显示轮廓?

标签: javascript html css bootstrap-4


【解决方案1】:

您可能需要做一些javascript,首先为要修改的元素附加一个id,然后控制您在哪个幻灯片中修改已保存元素的类。

【讨论】:

    猜你喜欢
    • 2019-10-07
    • 1970-01-01
    • 1970-01-01
    • 2021-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多