html5中,input 的属性type="range",样式怎样美化
1个回答
展开全部
/* range控件 */
input[type=range] {
display: block;
position: relative;
width: 480px;
height: 48px;
margin: 8px 0;
padding: 0 64px;
background: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
cursor: pointer;
}
input[type=range]:hover:before,
input[type=range]:hover:after {
color: #608000;
}
input[type=range]:hover::-webkit-slider-runnable-track {
background-color: #85b200;
}
input[type=range]:hover::-moz-range-track {
background-color: #85b200;
}
input[type=range]:focus::-webkit-slider-runnable-track {
background-color: #85b200;
}
/*range前后图标*/
input[type=range]:before,
input[type=range]:after {
content: "";
display: block;
position: absolute;
top: 8px;
width: 32px;
height: 32px;
line-height: 32px;
font-size: 32px;
color: #000;
text-align: center;
font-family: "你的图标字体名称" !important;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
-webkit-font-smoothing: antialiased;
-ms-font-smoothing: antialiased;
-o-font-smoothing: antialiased;
font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
input[type=range]:before {
left: 16px;
}
input[type=range]:after {
right: 16px;
}
input[type=range]#sort_tra:before {
content: "\e000";
}
input[type=range]#sort_tra:after {
content: "\e001";
}
/*range中心圆点*/
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
height: 18px;
width: 18px;
border-radius: 100%;
background-color: #fff;
cursor: pointer;
margin-top: -7px;
-webkit-box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
}
input[type=range]::-moz-range-thumb {
-moz-appearance: none;
appearance: none;
height: 18px;
width: 18px;
border-radius: 100%;
background-color: #fff;
cursor: pointer;
-moz-box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
}
input[type=range]::-ms-thumb {
-ms-appearance: none;
appearance: none;
height: 18px;
width: 18px;
border-radius: 100%;
background-color: #fff;
cursor: pointer;
-ms-box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
}
input[type=range]::slider-thumb {
-webkit-appearance: none;
appearance: none;
height: 18px;
width: 18px;
border-radius: 100%;
background-color: #fff;
cursor: pointer;
margin-top: -6px;
-webkit-box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
}
/*range轨道*/
input[type=range]::-webkit-slider-runnable-track {
width: 100%;
height: 4px;
background-color: #aaa;
border-radius: 4px;
cursor: pointer;
}
input[type=range]::-moz-range-track {
width: 100%;
height: 4px;
background-color: #aaa;
border-radius: 4px;
cursor: pointer;
}
input[type=range]::-ms-track {
width: 100%;
height: 3px;
border-color: transparent;
color: transparent;
border-radius: 3px;
background: transparent;
cursor: pointer;
}
/*已达进度*/
input[type=range]::-ms-fill-lower {
background-color: #85b200;
}
/*未达进度*/
input[type=range]::-ms-fill-upper {
background-color: #aaa;
}
input[type=range]::-ms-ticks-before {
display: none;
}
input[type=range]::-ms-ticks-after {
display: none;
}
不包含range的标题,前后图标用的字体图标,可以自行更换。经兼容测试,进度效果仅在IE9及以上版本有效(不影响实际使用)。
Chromium浏览器效果如下:
IE9及以上:
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询