slick.js carousel how to remove numbers from slick-dots
Asked Answered
L

8

13

I've been looking through the slick-theme.css and I can't figure out how to hide the numbers inserted after the dots.

Can anyone enlighten me?

Lannie answered 29/9, 2016 at 8:45 Comment(1)
I'm not sure what you mean. There shouldn't be any numbers inserted after the dots. Can you post a screenshot?Jovi
S
22

The official solution is this according to slick.css

.slick-dots li button { 
   font-size: 0; 
} 
Sensational answered 11/10, 2016 at 15:41 Comment(0)
K
5

The best way would it be to create your own dots on a pseudo element, since the dots you see come from the list-item.

That's how slick is doing it for their own theme:

.slick-dots li {
    position: relative;
    display: inline-block;
    width: 20px;
    height: 20px;
    margin: 0 5px;
    padding: 0;
    cursor: pointer;
}

.slick-dots li button {
    font-size: 0;
    line-height: 0;
    display: block;
    width: 20px;
    height: 20px;
    padding: 5px;
    cursor: pointer;
    color: transparent;
    border: 0;
    outline: none;
    background: transparent;
}

.slick-dots li button:before {
    content: '•';
    font-size: 22px;
    line-height: 20px;
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    text-align: center;
    opacity: .25;
    color: black;
}
Kamchatka answered 7/3, 2018 at 12:46 Comment(0)
S
4

Adding this worked for me

.slick-dots li button {
    display: none;
}
Stapleton answered 28/8, 2018 at 10:20 Comment(0)
C
3

Numbers can be removed by using the text-indent property.

.slick-dots li button {
   text-indent: -9999px;
}
Czardas answered 7/4, 2018 at 14:16 Comment(0)
H
1

You can remove text of the button with javascript like this:

  var dotNums = document.querySelectorAll(".slick-dots button");

  function removeText(item) {
    item.innerHTML = ""; // or put the text you need inside quotes
  }

  dotNums.forEach(removeText);
Hesione answered 8/11, 2019 at 10:52 Comment(1)
You should add some explanation to your answer.Bratcher
D
0

This is what I did to remove the numbers from the dots.

solution 1

setTimeout(function(){ const dots = document.querySelectorAll('.slick-dots li button') dots.forEach(dot=>dot.innerHTML="") },1000)

.slick-dots li button doesn't happen to be part of the DOM when the page loads. it's is added after the slider start sliding.

Recommended solution

.slick-dots li button { text-indent:-1000 }

Dramatist answered 10/5, 2021 at 22:55 Comment(0)
A
0
$(".slider").slick({
   customPaging: function(slider) {
      return '<button type="button"/>';
   }
});
Alms answered 16/4 at 16:41 Comment(1)
Thank you for your interest in contributing to the Stack Overflow community. This question already has a few answers—including some that have been validated by the community. Are you certain your approach hasn’t been given previously? If so, it would be useful to explain how your approach is different, under what circumstances your approach might be preferred, and/or why you think the previous answers aren’t sufficient. Can you kindly edit your answer to offer an explanation?Singularize
M
-3

you can use jquery to remove the dots

Docs

$('.your-slider').slick({
   dots: false
});
Mekka answered 6/2, 2018 at 10:18 Comment(1)
I believe the OP is asking for how to remove numbers which appear after the dots, and not the dots themselvesCollarbone

© 2022 - 2024 — McMap. All rights reserved.