我想自定义 html5 input[range] 在垂直时的外观。
想要避免像 transform:rotate 这样的 CSS 3 指令,它会使 UI 布局复杂化。
Webkit css 属性在我的上下文中被识别,其他供应商在我的情况下没有用。
定制适用于水平默认 slider ,但不适用于垂直 slider ,您可以在这里查看:
jsFiddle:http://jsfiddle.net/QU5VD/1/
否则,代码如下:
HTML
<input type="range" class="vHorizon" />
<input type="range" class="vVertical" />
CSS
input[type="range"].vHorizon {
-webkit-appearance: none;
background-color: pink;
width: 200px;
height:10px;
}
input[type="range"].vVertical {
-webkit-appearance: slider-vertical;
background-color: pink;
width: 10px;
height:200px;
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
background-color: red;
width: 20px;
height: 20px;
}
最佳答案
******更新的答案****
如果我没理解错的话,你是想让你垂直的看起来像你的水平的样子?如果是这样:
input[type=range].vVertical {
-webkit-appearance: none;
background-color: green;
width: 200px;
height:10px;
-webkit-transform:rotate(90deg);
-moz-transform:rotate(90deg);
-o-transform:rotate(90deg);
-ms-transform:rotate(90deg);
transform:rotate(90deg);
z-index: 0;
}
input[type=range].vHorizon {
-webkit-appearance: none;
background-color: pink;
height: 10px;
width:200px;
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
background-color: red;
width: 20px;
height: 20px;
}
fiddle <--已更新
关于css - 如何仅使用 css 自定义 html5 输入范围 slider 垂直?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16796831/