当先锋百科网

首页 1 2 3 4 5 6 7

这是Bootstrap中关于轮播图的代码 :

<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
  <div class="carousel-indicators">
    <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
    <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
    <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
  </div>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="自己的图片路径" class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="自己的图片路径" class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="自己的图片路径" class="d-block w-100" alt="...">
    </div>
  </div>
  <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Previous</span>
  </button>
  <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Next</span>
  </button>
</div>

原始焦点效果如图:

 自定义之后如图:

方法 :

1、找到自己的  bootstrap-5.1.1-dist\css\bootstrap.css 

2、查找  .carousel-indicators

 3、在自己css中加入以下代码 (可根据bootstrap.css找到的 .carousel-indicators [data-bs-target]   相关图片位置的代码自行调整)

.carousel-indicators [data-bs-target]{  
    margin: 0 5px;
    background: url(./img/zhu.png) left no-repeat;  /*图片路径,我这边为相对路径*/
}

4、完成 (注意自定义的图片需要设置小些,大概像素值30-40左右)