我无法在台阶上打点(有5个台阶)。我无法将+
放在拇指内。
我尝试设置
input[type=range]::-webkit-slider-thumb::before {
content: '+';
color: '#FFF';
}
但是,这没有在拇指内显示任何东西。如何将+
放在拇指内以及在每个步骤上都加点?
input[type=range] {
-webkit-appearance: none;
width: 300px;
margin: -4.5px 0;
}
input[type=range]:focus {
outline: none;
}
input[type=range]::-webkit-slider-runnable-track {
width: 100%;
height: 50px;
cursor: pointer;
box-shadow: 0px 0px 0px rgba(0, 0, 0, 0), 0px 0px 0px rgba(13, 13, 13, 0);
background: rgba(70, 134, 146, 0.5);
border-radius: 25px;
border: 0px solid rgba(0, 0, 0, 0);
}
input[type=range]::-webkit-slider-thumb {
box-shadow: 1.1px 1.1px 6.8px rgba(0, 0, 0, 0), 0px 0px 1.1px rgba(13, 13, 13, 0);
border: 0px solid #000000;
height: 40px;
width: 40px;
border-radius: 49px;
background: #5ab6c5;
cursor: pointer;
-webkit-appearance: none;
margin-top: 4.5px;
}
input[type=range]::-webkit-slider-thumb::before {
content: '+';
color: '#FFF';
}
input[type=range]:focus::-webkit-slider-runnable-track {
background: rgba(70, 134, 146, 0.5);
}
input[type=range]::-moz-range-track {
width: 100%;
height: 50px;
cursor: pointer;
box-shadow: 0px 0px 0px rgba(0, 0, 0, 0), 0px 0px 0px rgba(13, 13, 13, 0);
background: rgba(70, 134, 146, 0.5);
border-radius: 25px;
border: 0px solid rgba(0, 0, 0, 0);
}
input[type=range]::-moz-range-thumb {
box-shadow: 1.1px 1.1px 6.8px rgba(0, 0, 0, 0), 0px 0px 1.1px rgba(13, 13, 13, 0);
border: 0px solid #000000;
height: 41px;
width: 40px;
border-radius: 49px;
background: #5ab6c5;
cursor: pointer;
}
input[type=range]::-ms-track {
width: 100%;
height: 50px;
cursor: pointer;
background: transparent;
border-color: transparent;
color: transparent;
}
input[type=range]::-ms-fill-lower {
background: rgba(70, 134, 146, 0.5);
border: 0px solid rgba(0, 0, 0, 0);
border-radius: 50px;
box-shadow: 0px 0px 0px rgba(0, 0, 0, 0), 0px 0px 0px rgba(13, 13, 13, 0);
}
input[type=range]::-ms-fill-upper {
background: rgba(70, 134, 146, 0.5);
border: 0px solid rgba(0, 0, 0, 0);
border-radius: 50px;
box-shadow: 0px 0px 0px rgba(0, 0, 0, 0), 0px 0px 0px rgba(13, 13, 13, 0);
}
input[type=range]::-ms-thumb {
box-shadow: 1.1px 1.1px 6.8px rgba(0, 0, 0, 0), 0px 0px 1.1px rgba(13, 13, 13, 0);
border: 0px solid #000000;
width: 40px;
border-radius: 49px;
background: #5ab6c5;
cursor: pointer;
height: 41px;
}
input[type=range]:focus::-ms-fill-lower {
background: rgba(70, 134, 146, 0.5);
}
input[type=range]:focus::-ms-fill-upper {
background: rgba(70, 134, 146, 0.5);
}
<body>
<input type="range" min=1 max=5 step=1 value=1 />
</body>
答案 0 :(得分:1)
跳过-moz
和-ms
前缀,但复制起来并不难。将加号图标替换为白色(当然是.png
),您就可以使用了。
* {
box-sizing: border-box;
}
body {
font-family: sans-serif;
font-size: 20px;
line-height: 20px;
color: black;
background: #3f626a;
}
.range {
position: relative;
}
input[type="range"] {
-webkit-appearance: none;
display: block;
margin: 0;
width: 100%;
background: transparent;
}
input[type="range"]:focus {
outline: none;
}
input[type="range"]::-webkit-slider-runnable-track {
-webkit-appearance: none;
width: 100%;
color: transparent;
background: lightgray;
border-radius: 999px;
border: none;
padding: 5px;
box-shadow: 0px 0px 0px rgba(0, 0, 0, 0), 0px 0px 0px rgba(13, 13, 13, 0);
background: rgba(70, 134, 146, 0.5);
border: 0px solid rgba(0, 0, 0, 0);
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
cursor: pointer;
height: 40px;
width: 40px;
border-radius: 30px;
background: black;
box-shadow: 0px 2px 10px -2px black(1);
position: relative;
z-index: 2;
box-shadow: 1.1px 1.1px 6.8px rgba(0, 0, 0, 0), 0px 0px 1.1px rgba(13, 13, 13, 0);
border: 0px solid #000000;
background: url(https://image.flaticon.com/icons/svg/149/149145.svg) #75b4c3;
background-size: 43%;
background-position: center;
background-repeat: no-repeat;
}
input[type="range"]::-webkit-slider-thumb::before {
content: '+';
position: absolute;
top: 0;
left: 0;
width: 100%;
color: red;
}
.ticks {
position: absolute;
z-index: -1;
top: 0%;
left: 0;
right: 0;
bottom: 0;
display: flex;
justify-content: space-between;
padding: 22.5px;
}
.tick {
position: relative;
z-index: 1;
display: flex;
justify-content: center;
width: 4px;
background: #558590;
height: 4px;
border-radius: 100%;
line-height: 50px;
margin-bottom: 20px;
}
<div class="range">
<input type="range" min="0" max="5">
<div class="ticks">
<span class="tick"></span>
<span class="tick"></span>
<span class="tick"></span>
<span class="tick"></span>
<span class="tick"></span>
<span class="tick"></span>
</div>
</div>