滑动时更改 jquery ui 滑块的颜色
我一直在寻找有关如何执行此操作的答案,但我似乎无法弄清楚(甚至查看 jquery ui 主题文档)。当我从左向右移动滑块时,我希望滑块旋钮左侧的部分更改为橙色(而不是默认的灰色)。
jquery theme-roll 生成了下面的 css。据推测 .ui-widget-header 背景颜色会控制这一点,但似乎没有。向任何其他类添加背景颜色也不会。知道我如何解决这个问题,以便当你水平滑动时你会得到不同的颜色吗?
JQUERY:
$(document).ready(function(){
$("#tasks_time").slider({
value: 1,
min: 0,
max: 72,
step: 1,
slide: function() {
update();
}
});
$("#tasks_done").slider({
value: 5,
min: 0,
max: 1000,
step: 10,
slide: function() {
update();
}
});
HTML:
Finish these items in <span id="curr-tasks_time" class="calc_number">1</span> hours
<div id="tasks_time">
</div>
CSS:
.ui-widget-content { border: 1px solid #ccc; background: #ff9900 url(images/ui-bg_flat_100_ff9900_40x100.png) 50% 50% repeat-x; color: #222222; }
.ui-widget-header { border: 1px solid #aaaaaa; background: #797979 url(images/ui-bg_highlight-soft_75_797979_1x100.png) 50% 50% repeat-x; color: #222222; font-weight: bold; }
.ui-slider { position: relative; text-align: left; }
.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; }
.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
.ui-slider-horizontal { height: .8em; }
.ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; }
.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
.ui-slider-horizontal .ui-slider-range-min { left: 0; }
.ui-slider-horizontal .ui-slider-range-max { right: 0;}
这是示例
提前感谢您的帮助!
I've been looking around for an answer on how to do this and I can't seem to figure it out (even looking at the jquery ui themeing documentation). As I move the slider from left to right, I want the section on the left side of the slider-knob to change to orange (instead of the default grey).
The jquery theme-roll generated the css below. Presumably the .ui-widget-header background-color would control this, but it does't seem to. Neither does adding a background color to any other class. Any idea how I fix this so that as you slide horizontally you get a different color?
JQUERY:
$(document).ready(function(){
$("#tasks_time").slider({
value: 1,
min: 0,
max: 72,
step: 1,
slide: function() {
update();
}
});
$("#tasks_done").slider({
value: 5,
min: 0,
max: 1000,
step: 10,
slide: function() {
update();
}
});
HTML:
Finish these items in <span id="curr-tasks_time" class="calc_number">1</span> hours
<div id="tasks_time">
</div>
CSS:
.ui-widget-content { border: 1px solid #ccc; background: #ff9900 url(images/ui-bg_flat_100_ff9900_40x100.png) 50% 50% repeat-x; color: #222222; }
.ui-widget-header { border: 1px solid #aaaaaa; background: #797979 url(images/ui-bg_highlight-soft_75_797979_1x100.png) 50% 50% repeat-x; color: #222222; font-weight: bold; }
.ui-slider { position: relative; text-align: left; }
.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; }
.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
.ui-slider-horizontal { height: .8em; }
.ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; }
.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
.ui-slider-horizontal .ui-slider-range-min { left: 0; }
.ui-slider-horizontal .ui-slider-range-max { right: 0;}
Here's an example
Thanks in advance for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有一个示例
http://jsfiddle.net/amkrtchyan/EAaLK/2/
和jquery代码......
ther is a example
http://jsfiddle.net/amkrtchyan/EAaLK/2/
and a jquery code......
阿拉姆的回答对我不起作用。另外,jsfiddle 演示似乎没有达到预期的效果。
这是一个更高级的版本,可以使用,并且包含多种颜色。
您可以摆弄它并设置任意数量的颜色和组合:
HTML:
CSS:
Javascript:
DEMO: http://codepen.io/anon/pen/obWzaQ
Aram's answer didn't work for me. Also the jsfiddle demo doesn't seem to do what it's supposed to.
Here is a more advanced version that does work, and includes multiple colors.
You can fiddle with it and set as many colors and combinations as you'd like:
The HTML:
The CSS:
The Javascript:
DEMO: http://codepen.io/anon/pen/obWzaQ
试试这个:
作为奖励,如果您想更改小拖动手柄的颜色,请使用以下命令:
Try this:
As a bonus, if you want to change the color of the little drag handle, use this: