How to customize the HTML5 input range type looks using CSS?

后端 未结 10 2292
粉色の甜心
粉色の甜心 2020-11-27 15:24

I want to customize the looks of the range input type in HTML5 to look something like a progress bar. I\'ve tried applying some common CSS attributes using CSS class but it

10条回答
  •  没有蜡笔的小新
    2020-11-27 15:55

    You can in Webkit, through the -webkit-slider-thumb pseudo-element: http://jsfiddle.net/leaverou/BNm8j/

    input[type=range] {
        -webkit-appearance: none;
        background-color: silver;
        width: 200px;
        height:20px;
    }
    
    input[type="range"]::-webkit-slider-thumb {
        -webkit-appearance: none;
        background-color: #666;
        opacity: 0.5;
        width: 10px;
        height: 26px;
    }

    Although the others are right about input type="range" not being the right element for the job.

    You should use the element and for browsers that don't support it, this polyfill: http://lea.verou.me/polyfills/progress/

提交回复
热议问题