Formatting of bootstrap 4 carousel indicators

Asked

Viewed 1,044 times

0

By default, bootstrap carousel indicators are narrow as lines, like to know how to leave polka dots in place of originals. inserir a descrição da imagem aqui

2 answers

0


The indicators (the lines you quoted) are within a list with class .carousel-indicators. Just change the li’s of this element to "polka dots", changing the width and the height equal values and adding border-radius: 50% to make them round:

.carousel-indicators li {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

The indicators will have 10x10 pixels. If you want to increase or decrease, just change these values.

Note that if your . css is being loaded before the Bootstrap . css, you should use !important on the estates width and height:

.carousel-indicators li {
  width: 10px !important;
  height: 10px !important;
  border-radius: 50%;
}

See example:

.carousel-indicators li {
  width: 10px !important;
  height: 10px !important;
  border-radius: 50%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>

<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://www.cleverfiles.com/howto/wp-content/uploads/2016/08/mini.jpg" alt="First slide">
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="https://www.cleverfiles.com/howto/wp-content/uploads/2016/08/mini.jpg" alt="Second slide">
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="https://www.cleverfiles.com/howto/wp-content/uploads/2016/08/mini.jpg" 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>

  • was very helpful thank you :)

-1

  • It worked, thank you very much :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.