我的范围滑块无法在Internet Explorer 11上运行,除非所有其他浏览器都支持此插件100%且工作正常。
.range-slider {
margin: 30px 0 0;
display: inline-block;
width: 100%;
box-sizing: border-box;
position: relative;
}
.range-slider>input {
opacity: 0;
width: 100%;
position: relative;
z-index: 5;
-webkit-appearance: none;
}
.range-slider>input::-webkit-slider-thumb {
-webkit-appearance: none;
z-index: 100;
position: relative;
width: 50px;
height: 30px;
-webkit-border-radius: 10px;
}
.range-slider>span.slider-container {
// min-height: 110px;
display: inline-block;
position: absolute;
top: 0px;
left: -8px;
right: 46px;
z-index: 3;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.range-slider>span.slider-container>span.bar {
background-color: #e5e5e5;
display: inline-block;
position: absolute;
z-index: 1;
top: 17px;
left: 0;
right: 0;
height: 3px;
overflow: hidden;
border-radius: 10px;
}
.range-slider>span.slider-container>span.bar>span {
background: #d7302d;
background: -webkit-gradient(left top, right bottom, color-stop(0, #d7302d), color-stop(100%, #e82573));
background: linear-gradient(135deg, #d7302d 0, #e82573 100%);
display: inline-block;
float: left;
height: 3px;
width: 0%;
}
.range-slider>span.slider-container>span.bar-btn {
position: absolute;
text-align: center;
top: 0;
color: #fff;
font: 600 16px "Roboto Condensed", sans-serif;
z-index: 1;
text-align: center;
width: 38px;
height: 38px;
line-height: 38px;
}
.range-slider>span.slider-container>span.bar-btn:after {
content: "";
background-color: #cc202e;
border-radius: 20px;
width: 38px;
height: 38px;
display: inline-block;
position: absolute;
left: 0;
top: 0;
z-index: -1;
-webkit-box-shadow: 0 0 0 4px #cc202e;
box-shadow: 0 0 0 4px rgba(204, 32, 46, 0.2)
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h1>Please Select</h1>
<input class="slider" value="20" min="0" max="100" name="rangeslider" type="range" />
File imgFile = new File(getIntent().getStringExtra("URI").replace("file://", ""));
过去两天我一直在用这个代码敲打我的脑袋。我无法从许多网站得到任何答案。我已经搜索了google和w3schools以获得帮助,但我不这么认为他们可以帮助我。
所以,我来到这里并发布了问题
如果有人能够解决这个问题,我将非常感激。
答案 0 :(得分:1)
您可以使用input
和change
事件在所有浏览器中获得一致的用户体验:
$(this).on("change input", function() {
updateSlider(this);
});
$(function() {
$(".slider").rangeslider();
});
$.fn.rangeslider = function(options) {
var obj = this;
var defautValue = obj.attr("value");
obj.wrap("<span class='range-slider'></span>");
obj.after("<span class='slider-container'><span class='bar'><span></span></span><span class='bar-btn'><span>0</span></span></span>");
$(this).on("change input", function() {
updateSlider(this)
});
return obj;
};
function updateSlider(passObj) {
var obj = $(passObj);
var value = obj.val();
var min = obj.attr("min");
var max = obj.attr("max");
var range = Math.round(max - min);
var percentage = Math.round((value - min) * 100 / range);
var nextObj = obj.next();
nextObj.find("span.bar-btn").css("left", percentage + "%");
nextObj.find("span.bar > span").css("width", percentage + "%");
nextObj.find("span.bar-btn > span").text(percentage);
};
&#13;
.range-slider {
margin: 30px 0 0;
display: inline-block;
width: 100%;
box-sizing: border-box;
position: relative;
}
.range-slider>input {
opacity: 0;
width: 100%;
position: relative;
z-index: 5;
-webkit-appearance: none;
}
.range-slider>input::-webkit-slider-thumb {
-webkit-appearance: none;
z-index: 100;
position: relative;
width: 50px;
height: 30px;
-webkit-border-radius: 10px;
}
.range-slider>span.slider-container {
// min-height: 110px;
display: inline-block;
position: absolute;
top: 0px;
left: -8px;
right: 46px;
z-index: 3;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.range-slider>span.slider-container>span.bar {
background-color: #e5e5e5;
display: inline-block;
position: absolute;
z-index: 1;
top: 17px;
left: 0;
right: 0;
height: 3px;
overflow: hidden;
border-radius: 10px;
}
.range-slider>span.slider-container>span.bar>span {
background: #d7302d;
background: -webkit-gradient(left top, right bottom, color-stop(0, #d7302d), color-stop(100%, #e82573));
background: linear-gradient(135deg, #d7302d 0, #e82573 100%);
display: inline-block;
float: left;
height: 3px;
width: 0%;
}
.range-slider>span.slider-container>span.bar-btn {
position: absolute;
text-align: center;
top: 0;
color: #fff;
font: 600 16px "Roboto Condensed", sans-serif;
z-index: 1;
text-align: center;
width: 38px;
height: 38px;
line-height: 38px;
}
.range-slider>span.slider-container>span.bar-btn:after {
content: "";
background-color: #cc202e;
border-radius: 20px;
width: 38px;
height: 38px;
display: inline-block;
position: absolute;
left: 0;
top: 0;
z-index: -1;
-webkit-box-shadow: 0 0 0 4px #cc202e;
box-shadow: 0 0 0 4px rgba(204, 32, 46, 0.2)
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h1>Please Select</h1>
<input class="slider" value="20" min="0" max="100" name="rangeslider" type="range" />
&#13;
答案 1 :(得分:1)
只需将旧代码替换为
$(function() {
$(".slider").rangeslider();
});
$.fn.rangeslider = function(options) {
var obj = this;
var defautValue = obj.attr("value");
obj.wrap("<span class='range-slider'></span>");
obj.after("<span class='slider-container'><span class='bar'><span></span></span><span class='bar-btn'><span>0</span></span></span>");
$(obj).on("change", function() {
updateSlider(this)
});
return obj;
};
答案 2 :(得分:0)
看起来您需要使用jquery onchange
来更新滑块对象并触发updateSlider()
函数,因为它在IE 11中有点不稳定但它开始更新它, IE,你可以进一步改进,见下面的代码
$(function() {
$(".slider").rangeslider();
});
$.fn.rangeslider = function(options) {
var obj = this;
var defautValue = obj.attr("value");
obj.wrap("<span class='range-slider'></span>");
obj.after("<span class='slider-container'><span class='bar'><span></span></span><span class='bar-btn'><span>0</span></span></span>");
$(obj).on("change", function() {
updateSlider(this)
});
return obj;
};
function updateSlider(passObj) {
var obj = $(passObj);
var value = obj.val();
var min = obj.attr("min");
var max = obj.attr("max");
var range = Math.round(max - min);
var percentage = Math.round((value - min) * 100 / range);
var nextObj = obj.next();
nextObj.find("span.bar-btn").css("left", percentage + "%");
nextObj.find("span.bar > span").css("width", percentage + "%");
nextObj.find("span.bar-btn > span").text(percentage);
};
.range-slider {
margin: 30px 0 0;
display: inline-block;
width: 100%;
box-sizing: border-box;
position: relative;
}
.range-slider>input {
opacity: 0;
width: 100%;
position: relative;
z-index: 5;
-webkit-appearance: none;
}
.range-slider>input::-webkit-slider-thumb {
-webkit-appearance: none;
z-index: 100;
position: relative;
width: 50px;
height: 30px;
-webkit-border-radius: 10px;
}
.range-slider>span.slider-container {
// min-height: 110px;
display: inline-block;
position: absolute;
top: 0px;
left: -8px;
right: 46px;
z-index: 3;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.range-slider>span.slider-container>span.bar {
background-color: #e5e5e5;
display: inline-block;
position: absolute;
z-index: 1;
top: 17px;
left: 0;
right: 0;
height: 3px;
overflow: hidden;
border-radius: 10px;
}
.range-slider>span.slider-container>span.bar>span {
background: #d7302d;
background: -webkit-gradient(left top, right bottom, color-stop(0, #d7302d), color-stop(100%, #e82573));
background: linear-gradient(135deg, #d7302d 0, #e82573 100%);
display: inline-block;
float: left;
height: 3px;
width: 0%;
}
.range-slider>span.slider-container>span.bar-btn {
position: absolute;
text-align: center;
top: 0;
color: #fff;
font: 600 16px "Roboto Condensed", sans-serif;
z-index: 1;
text-align: center;
width: 38px;
height: 38px;
line-height: 38px;
}
.range-slider>span.slider-container>span.bar-btn:after {
content: "";
background-color: #cc202e;
border-radius: 20px;
width: 38px;
height: 38px;
display: inline-block;
position: absolute;
left: 0;
top: 0;
z-index: -1;
-webkit-box-shadow: 0 0 0 4px #cc202e;
box-shadow: 0 0 0 4px rgba(204, 32, 46, 0.2)
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h1>Please Select</h1>
<input class="slider" value="20" min="0" max="100" name="rangeslider" type="range" />