BoobaGump
BoobaGump

Reputation: 535

Bootstrap-slider custom handle

I really don't understand why I can't manage to replace the original star handle by a picture of my own. Let's rely on that plunker to understand. I read the author's documentation on that matter: example 10

On the previous plunker I did as it's written that:

HTML:

<input id="ex10" type="text" data-slider-handle="custom"/>

CSS:

.slider-handle.custom {
  background: transparent url("http://icons.iconarchive.com/icons/custom-icon-design/pretty-office-8/128/Accept-icon.png");
}

The url background linked to the picture I want to see as handle. (Replacing the default star).

As you can see here: Plunker Picture - Enable to set background handle

New picture with Alexandr's comment below: Doesn't seem to change anything.

Alexandr's comment

Upvotes: 4

Views: 2661

Answers (3)

Anis D
Anis D

Reputation: 761

You should override slider-handle.custom::before

.slider-handle.custom::before {
      display:none
}

Upvotes: 0

BoobaGump
BoobaGump

Reputation: 535

Change this :

.slider-handle.custom::before {
  line-height: 20px;
  font-size: 20px;
  content: '\2605';
  color: #726204;
}

to this :

 .slider-handle.custom::before {
      line-height: 20px;
      font-size: 20px;
      content: "url-of-your-picture";
      color: #726204;
    }

You may have to do some adjustment to the line-height depending on the size of custom handle you want to use.

Upvotes: 2

Jasmin Skopljak
Jasmin Skopljak

Reputation: 19

So if you instantiated slider then all you need to do is change your CSS

.slider-handle.custom {
  background: transparent none;
  /* Add your background image */
  background-image: url("http://icons.iconarchive.com/icons/custom-icon-design/pretty-office-8/128/Accept-icon.png");
  background-size: contain;
}

/* Or display content like unicode characters or fontawesome icons */
.slider-handle.custom::before {
  line-height: 20px;
  font-size: 20px;
  /* Comment this because you will not use star */
  /*content: '\2605'; /*unicode star character*/
  color: #726204;*/
}

Upvotes: 0

Related Questions