HTML:将Bootstrap Carousel图标从单杠更改为圆形

时间:2019-07-08 16:40:02

标签: html css twitter-bootstrap

如何将Bootstrap Carousel幻灯片图标更改为Circles?当前它们是单杠。 https://www.w3schools.com/bootstrap/bootstrap_carousel.asp

*当前为:**

enter image description here

预期目标:

enter image description here

2 个答案:

答案 0 :(得分:0)

尝试此代码

<!DOCTYPE html>
<html>
<head>
  <title></title>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  <style type="text/css">
.carousel-indicators li {
    box-sizing: content-box;
    -ms-flex: 0 1 auto;
    flex: 0 1 auto;
    width: 30px;
    height: 30px;
    line-height: 30px;
    border-radius: 50%;
    text-align: center;
    margin-right: 3px;
    margin-left: 3px;
    text-indent: unset;
    cursor: pointer;
    background-color: #fff;
    background-clip: unset;
    border-top: 0;
    border-bottom: 0;
    opacity: .5;
    transition: opacity .6s ease;
  }
  </style>
</head>
<body>
  <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
  <ol class="carousel-indicators">
    <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active">1</li>
    <li data-target="#carouselExampleIndicators" data-slide-to="1">2</li>
    <li data-target="#carouselExampleIndicators" data-slide-to="2">3</li>
  </ol>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img class="d-block w-100" src="https://images.unsplash.com/photo-1489216317223-a88355bd0e38?ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80" alt="First slide">
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="https://images.unsplash.com/photo-1474932525110-07bf2cd0de87?ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80" alt="Second slide">
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="https://images.unsplash.com/photo-1475010040281-9c4f94108f91?ixlib=rb-1.2.1&auto=format&fit=crop&w=624&q=80" 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>
<script
  src="https://code.jquery.com/jquery-3.4.1.min.js"
  integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
  crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>

答案 1 :(得分:0)

添加边界半径border-radius

.carousel-indicators > li {
    border-radius: 50%;
    }

请注意,您必须定位li类中的carousel-indicators标签,并且还必须50%而不是100%

#myCarousel-indicators > li {
  border-radius: 50%;
}

<ol id="myCarousel-indicators" class="carousel-indicators"></ol>