Disable track on HTML5 range input

后端 未结 2 1684
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-07 08:58

I\'m trying to find a way to prevent the user from clicking into the \"track\" portion of an HTML5 range input. Essentially, I only want the user to be able to use the \"han

2条回答
  •  我在风中等你
    2021-01-07 09:26

    It's possible through pointer-events at least on chrome.

    input[type=range] {
    pointer-events: none;
    }
    
    input[type=range]::-webkit-slider-thumb {
    pointer-events:auto;
    }
    

    This will disable clicking on the track and enable clicking only on slider thumbs.

提交回复
热议问题