How to style carousel dots?

52,406

Solution 1

Here you go. :)

nav.carousel:hover {
  cursor: default;
}

/* Hide the radio button */
nav.carousel input[type=radio] {
  display: none;
}

/* All styling takes place on the label element */
nav.carousel label {
  display: inline-block;
  background: #ddd;
  overflow: hidden;
  text-indent: -999px;
  border-radius: 100%;
  width: 10px;
  height: 10px;
  box-shadow: inset 0 1px 1px 0 #999;
}
nav.carousel label:hover {
  background: #bbb;
  cursor: pointer;
  box-shadow: inset 0 1px 1px 0 #777;
}
nav.carousel input:checked + label {
  background: linear-gradient(#00CFFF, #1584bc);
  box-shadow: inset 0 0 1px 1px #087DC0;
}
<nav class="carousel">
  <input id="carousel-item-1" type="radio" name="carousel-dots">
  <label for="carousel-item-1">Go to item 1</label>

  <input id="carousel-item-2" type="radio" name="carousel-dots" checked>
  <label for="carousel-item-2">Go to item 2</label>

  <input id="carousel-item-3" type="radio" name="carousel-dots"> 
  <label for="carousel-item-3">Go to item 3</label>

  <input id="carousel-item-4" type="radio" name="carousel-dots">
  <label for="carousel-item-4">Go to item 4</label>

  <input id="carousel-item-5" type="radio" name="carousel-dots">
  <label for="carousel-item-5">Go to item 5</label>

  <input id="carousel-item-6" type="radio" name="carousel-dots"> 
  <label for="carousel-item-6">Go to item 6</label>
</nav>

Solution 2

this is my example

enter image description here

.slick-dots {
  bottom: 50px;
  li button:before,
  li.slick-active button:before {
    color: transparent;
    opacity: 1;
  }
  li button:before{
    background-color: transparent;
    border: 4px solid #fff;
    border-radius: 50%;
    display: inline-block;
    height: 20px;
    width: 20px;

  }
  li.slick-active button:before {
    background-color: #fff;
  }
}

Solution 3

I threw this together which does it purely with HTML and CSS: http://jsfiddle.net/kajrttgv/2

<div class="container">
    <span class="dot"></span>
    <span class="dot active"></span>
    <span class="dot"></span>
</div>

.dot {
    background-color: #eee;
    border: 1px solid #666;
    border-radius: 5px;
    box-shadow: inset 1px 1px 1px #888;
    display: inline-block;
    height: 10px;
    width: 10px;
}
.dot.active {
    background-color: #41ABE5;
    box-shadow: inset 2px 0px 2px -2px #333;
}
Share:
52,406
iori
Author by

iori

Web Developer

Updated on July 18, 2022

Comments

  • iori
    iori almost 2 years

    How do I style my carousel dots to become like this ?

    enter image description here

    Here is what I have now.

    enter image description here

    Here is how I style it.

    .slick-dots {
      position: absolute;
      bottom: -45px;
      list-style: none;
      display: block;
      text-align: center;
      padding: 0;
      width: 100%;
    }
    .slick-dots li {
      position: relative;
      display: inline-block;
      height: 20px;
      width: 20px;
      margin: 0 5px;
      padding: 0;
      cursor: pointer;
    }
    .slick-dots li button {
      border: 0;
      background: transparent;
      display: block;
      height: 20px;
      width: 20px;
      outline: none;
      line-height: 0;
      font-size: 0;
      color: transparent;
      padding: 5px;
      cursor: pointer;
    }
    .slick-dots li button:hover,
    .slick-dots li button:focus {
      outline: none;
    }
    .slick-dots li button:hover:before,
    .slick-dots li button:focus:before {
      opacity: 1;
    }
    .slick-dots li button:before {
      position: absolute;
      top: 0;
      left: 0;
      content: "•";
      width: 20px;
      height: 20px;
      font-family: "slick";
      font-size: 6px;
      line-height: 5px;
      text-align: center;
      color: black;
      opacity: 0.25;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
    }
    .slick-dots li.slick-active button:before {
      color: black;
      opacity: 0.75;
    }
    

    HTML

    <div class="row slick">
        // a bunch of images
    </div>
    
  • iori
    iori over 9 years
    Thanks for your solution. Do you have them in JSFiddle ?
  • dcsan
    dcsan about 9 years
    do we need to style each one? what if there aer 20 dots?
  • Zaqx
    Zaqx about 9 years
    @dcsan not sure what you mean by style each one. CSS describes styles to be applied if elements meet the criteria laid out in the CSS selector. Nowhere in the CSS in this example do I have a selector that styles an individual dot. As such the number of dots are irrelevant; there could be 20 dots or 100000 dots it makes no difference to the styling in this example. Does that answer your question?