2015-04-19 23 views
0

我試圖在webkit上設置範圍輸入的樣式。在Firefox上一切正常,但webkit在軌道上顯示奇怪的白點。webkit上的範圍輸入中的奇怪的白點

我看過一篇關於這方面的文章,並從中獲得靈感(link)。

現在這裏是演示。正如你所看到的,我無法擺脫白點。

body { 
 
    padding: 30px; 
 
    background-color: black; 
 
} 
 
input[type=range] { 
 
    /*removes default webkit styles*/ 
 
    -webkit-appearance: none; 
 
    /*required for proper track sizing in FF*/ 
 
    width: 300px; 
 
} 
 
input[type=range]::-webkit-slider-runnable-track { 
 
    width: 300px; 
 
    height: 5px; 
 
    background: black; 
 
    border: none; 
 
    border-radius: 3px; 
 
    outline: none; 
 
} 
 
input[type=range]::-webkit-slider-thumb { 
 
    -webkit-appearance: none; 
 
    border: none; 
 
    height: 16px; 
 
    width: 16px; 
 
    border-radius: 50%; 
 
    background: goldenrod; 
 
    margin-top: -4px; 
 
} 
 
input[type=range]:focus { 
 
    outline: none; 
 
} 
 
input[type=range]:focus::-webkit-slider-runnable-track { 
 
    background: #ccc; 
 
}
<input type="range">

它必須是非常簡單的,但我仍然爲此而努力。

謝謝

+0

我想你很可能通過你的自我...添加接壤的邊界:1px的白色固體;爲輸入[類型=範圍] ..元素....不是嗎? – aston

+0

當我刪除它,我仍然有4個白點。 (更新帖子) –

回答

2

你之所以有四點是輸入標籤都有默認的背景色。即背景顏色:白色;來自用戶代理樣式表的

嘗試下面的CSS

input[type=range] { 
    -webkit-appearance: none; 
    border: 0px; 
    width: 300px; 
    background-color: transparent; 
} 
+0

謝謝,解決了。 –

+0

標記爲答案,如果它解決了...... :-) – aston

+0

@DARK_DUCK如果答案解決了您的問題,請不要忘記將答案標記爲正確 –