Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Putting Icon on Steps and Thumb of Input Type Range

Tags:

html

css

I am trying to make a custom design that looks like desiredImage

I could not put dots on the steps(there are 5 steps). I could not put + inside thumb.

I tried to set

input[type=range]::-webkit-slider-thumb::before {
  content: '+';
  color: '#FFF';
}

but this did not show anything inside the thumb. How can I put + inside thumb as well as put dots on each step?

input[type=range] {
  -webkit-appearance: none;
  width: 300px;
  margin: -4.5px 0;
}
input[type=range]:focus {
  outline: none;
}
input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 50px;
  cursor: pointer;
  box-shadow: 0px 0px 0px rgba(0, 0, 0, 0), 0px 0px 0px rgba(13, 13, 13, 0);
  background: rgba(70, 134, 146, 0.5);
  border-radius: 25px;
  border: 0px solid rgba(0, 0, 0, 0);
}
input[type=range]::-webkit-slider-thumb {
  box-shadow: 1.1px 1.1px 6.8px rgba(0, 0, 0, 0), 0px 0px 1.1px rgba(13, 13, 13, 0);
  border: 0px solid #000000;
  height: 40px;
  width: 40px;
  border-radius: 49px;
  background: #5ab6c5;
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: 4.5px;
}

input[type=range]::-webkit-slider-thumb::before {
  content: '+';
  color: '#FFF';
}

input[type=range]:focus::-webkit-slider-runnable-track {
  background: rgba(70, 134, 146, 0.5);
}
input[type=range]::-moz-range-track {
  width: 100%;
  height: 50px;
  cursor: pointer;
  box-shadow: 0px 0px 0px rgba(0, 0, 0, 0), 0px 0px 0px rgba(13, 13, 13, 0);
  background: rgba(70, 134, 146, 0.5);
  border-radius: 25px;
  border: 0px solid rgba(0, 0, 0, 0);
}
input[type=range]::-moz-range-thumb {
  box-shadow: 1.1px 1.1px 6.8px rgba(0, 0, 0, 0), 0px 0px 1.1px rgba(13, 13, 13, 0);
  border: 0px solid #000000;
  height: 41px;
  width: 40px;
  border-radius: 49px;
  background: #5ab6c5;
  cursor: pointer;
}
input[type=range]::-ms-track {
  width: 100%;
  height: 50px;
  cursor: pointer;
  background: transparent;
  border-color: transparent;
  color: transparent;
}
input[type=range]::-ms-fill-lower {
  background: rgba(70, 134, 146, 0.5);
  border: 0px solid rgba(0, 0, 0, 0);
  border-radius: 50px;
  box-shadow: 0px 0px 0px rgba(0, 0, 0, 0), 0px 0px 0px rgba(13, 13, 13, 0);
}
input[type=range]::-ms-fill-upper {
  background: rgba(70, 134, 146, 0.5);
  border: 0px solid rgba(0, 0, 0, 0);
  border-radius: 50px;
  box-shadow: 0px 0px 0px rgba(0, 0, 0, 0), 0px 0px 0px rgba(13, 13, 13, 0);
}
input[type=range]::-ms-thumb {
  box-shadow: 1.1px 1.1px 6.8px rgba(0, 0, 0, 0), 0px 0px 1.1px rgba(13, 13, 13, 0);
  border: 0px solid #000000;
  width: 40px;
  border-radius: 49px;
  background: #5ab6c5;
  cursor: pointer;
  height: 41px;
}
input[type=range]:focus::-ms-fill-lower {
  background: rgba(70, 134, 146, 0.5);
}
input[type=range]:focus::-ms-fill-upper {
  background: rgba(70, 134, 146, 0.5);
}
<body>
  <input type="range" min=1 max=5 step=1 value=1 />
</body>
like image 499
Malena T Avatar asked Mar 18 '19 16:03

Malena T


People also ask

How do you show the value of the range slider on the thumb of the slider?

You cannot display value in the thumb but you can attach a bubble to the thumb which will contain and display the value as you slide. Refer to this detailed article Show slider value. Here's a demo. Save this answer.

How do you put a range in input?

<input type="range"> <input> elements of type range let the user specify a numeric value which must be no less than a given value, and no more than another given value. The precise value, however, is not considered important.

Can I use webkit slider thumb?

::-webkit-slider-thumb Non-standard: This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.


1 Answers

Skipped -moz and -ms prefix, but won't be that difficult to replicate. Replace the plus icon with a white one (.png ofcourse) and you are good to go.

* {
  box-sizing: border-box;
}

body {
  font-family: sans-serif;
  font-size: 20px;
  line-height: 20px;
  color: black;
  background: #3f626a;
}

.range {
  position: relative;
}

input[type="range"] {
  -webkit-appearance: none;
  display: block;
  margin: 0;
  width: 100%;
  background: transparent;
}

input[type="range"]:focus {
    outline: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  -webkit-appearance: none;
  width: 100%;
  color: transparent;
  background: lightgray;
  border-radius: 999px;
  border: none;
  padding: 5px;
  box-shadow: 0px 0px 0px rgba(0, 0, 0, 0), 0px 0px 0px rgba(13, 13, 13, 0);
  background: rgba(70, 134, 146, 0.5);
  border: 0px solid rgba(0, 0, 0, 0);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  cursor: pointer;
  height: 40px;
  width: 40px;
  border-radius: 30px;
  background: black;
  box-shadow: 0px 2px 10px -2px black(1);
  position: relative;
  z-index: 2;
  box-shadow: 1.1px 1.1px 6.8px rgba(0, 0, 0, 0), 0px 0px 1.1px rgba(13, 13, 13, 0);
  border: 0px solid #000000;
  background: url(https://image.flaticon.com/icons/svg/149/149145.svg) #75b4c3;
  background-size: 43%;
  background-position: center;
  background-repeat: no-repeat;
}

input[type="range"]::-webkit-slider-thumb::before {
  content: '+';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  color: red;
}

.ticks {
  position: absolute;
  z-index: -1;
  top: 0%;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  padding: 22.5px;
}

.tick {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  width: 4px;
  background: #558590;
  height: 4px;
  border-radius: 100%;
  line-height: 50px;
  margin-bottom: 20px;
}
<div class="range">
  <input type="range" min="0" max="5">
  <div class="ticks">
    <span class="tick"></span>
    <span class="tick"></span>
    <span class="tick"></span>
    <span class="tick"></span>
    <span class="tick"></span>
    <span class="tick"></span>
  </div>
</div>
like image 126
Jibin Joseph Avatar answered Sep 21 '22 19:09

Jibin Joseph