I am using jQuery UI horizontal slider. I need the position of the handle to be always within the slider. If I set the margin-left to minus of handle's width, the right position is within the container but the left position moves out of the container. I want to achieve this with CSS only. I don't want to add any wrapper div.
The following is the HTML code:
<div id="slider"></div>
<ul id="box">
<li>Fade with the above slider...</li>
<li>Fade with the above slider...</li>
</ul>
The CSS is as follows:
#box {
width: 200px;
height: 200px;
background-color: #ff0000;
}
#slider {
width: 200px;
}
.ui-slider .ui-slider-handle {
width: 20px;
margin-left: -10px;
}
Finally, the js code:
$(document).ready(function() {
$('#slider').slider({
min: 0,
max: 1,
step: 0.1,
value: 1
})
.bind("slide", function() {
//get the value of the slider with this call
var o = $(this).slider('value');
$(e).css('opacity', o)
});
});
Any help will be appreciated.