[英]JQUERY UI Slider With Image background and fully responsive
我想要實現的是:
當滑塊位於100%以外的任何給定點時:
要求是:
到目前為止,我嘗試使用背景圖像屬性來執行此操作,但是在響應性方面面臨上述限制。
HTML:
<div id="slider-range-min"></div>
CSS:
body {
padding:5vh;
}
#amount {
border: 0;
color: #f6931f;
font-weight: bold;
}
.ui-slider-horizontal {
height: 8vh;
}
.ui-widget-header {
border: 1px solid #aaaaaa;
background: #cccccc url(http://s13.postimg.org/e9jwzqsqv/gradient.png) no-repeat left top !important;
color: #222222;
font-weight: bold;
height: 15px;
width: 20vh;
position: absolute;
}
.ui-widget-content {
border: 1px solid #aaaaaa;
background: #f1f1f1 url("images/ui-bg_flat_75_ffffff_40x100.png") 50% 50% repeat-x;
color: #222222;
}
.ui-slider-horizontal .ui-slider-handle {
top: 0.6vh;
}
JS:
$(function () {
$("#slider-range-min").slider({
range: "min",
value: 37,
min: 30,
max: 50,
slide: function (event, ui) {
$("#amount").val("$" + ui.value);
}
});
$("#amount").val("$" + $("#slider-range-min").slider("value"));
});
查看CSS的結尾並自定義方式:
.ui-slider-handle { height:101%!important; margin-top:-0.75%}
關於背景:
采用 :
$( window ).resize(function() {
/*Here, you have to update the gradient width*/
$("#my_slider.ui-widget-header").width(/* here*/);
/*or other properties*/
$("#my_slider.ui-widget-header").css("...prop...","...value...");
});
簡而言之,CSS不足以使其具有100%的響應能力。 您必須使用一些JQuery。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.