Remove dotted outline from range input element in Firefox

前端 未结 10 976
忘了有多久
忘了有多久 2020-12-08 12:33

Firefox, since version 23, natively supports the element, but I couldn’t figure out how to remove the dotted outline. The following

10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-08 13:16

    If you can settle for a wrapping element (it's likely you already have a wrapping LI or P), you can use FireFox-only CSS to position the input out of view and reposition the track/thumb in view.

    • Note 1 - don't try to use translateX - I think FireFox uses that to actually slide the thumb - so stick with translateY
    • Note 2 - Be sure to test with keyboard navigation. You should only move the input by the smallest amount possible to get the dotted lines out of sight. If you position it waaay far away (translateY(-1000em)) - then you will break usability for keyboard navigation.

    Here ya go:

    HTML

    
    

    CSS

    .range-wrap {
        overflow: hidden;
    }
    input[type='range'] {
        -moz-transform: translateY(-3em);
    }
    input[type='range']::-moz-range-track {
        -moz-transform: translateY(3em)
    }
    input[type='range']::-moz-range-thumb {
        -moz-transform: translateY(3em);
    }
    

    http://jsfiddle.net/pF37g/98/

提交回复
热议问题