Show tick positions in custom range input

后端 未结 3 454
萌比男神i
萌比男神i 2020-12-30 13:37

Please take a look at the following CodePen. There you can see my custom range input. I want the tick positions of the slider to be shown and for that I added the datalist:<

3条回答
  •  星月不相逢
    2020-12-30 14:21

    I know my answer is way way late, but I keep coming back here when I try to find doing the same thing. I did manage to display tickmarks using the following settings.

    The code results in the following:

    * {
      box-sizing: border-box;
    }
    
    .slider {
      -webkit-appearance: none;
      appearance: none;
      width: 100%;
      height: 25px;
      background: #D3D3D3;
      outline: none;
      opacity: 0.7;
      -webkit-transition: .2s;
      transition: opacity .2s;
    }
    
    .slider:hover {
      opacity: 1;
    }
    
    .slider::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 25px;
      height: 25px;
      background: #FF0000;
      cursor: pointer;
    }
    
    .slider::-moz-range-thumb {
      width: 25px;
      height: 25px;
      background: #FF0000;
      cursor: pointer;
    }
    
    .sliderticks {
      display: flex;
      justify-content: space-between;
      padding: 0 10px;
    }
    
    .sliderticks p {
      position: relative;
      display: flex;
      justify-content: center;
      text-align: center;
      width: 1px;
      background: #D3D3D3;
      height: 10px;
      line-height: 40px;
      margin: 0 0 20px 0;
    }

    0

    1

    2

    3

    4

    5

提交回复
热议问题