1

Just getting acquainted with jQuery UI. So, this is a block of code from my view:

<label id="min">
    5000</label>
<div id="slider">
</div>
<label id="max">
    9000</label>

And a part of the script:

    $('#slider').slider({
        animate: true,
        range: true,
        min: 5000,
        max: 9000,
        values: [5000, 9000],
        slide: function (event, ui) {
            //doing smth
        }
    });    

Everything works fine, but the slider is stretched and takes the whole line. The labels are below and under it. I expected them all to be in one line.

What should I do to achieve it?

EDIT

This is what I am expecting:

Correct

And this is what I have:

Error

EDIT

I tried to override the slider css by adding the following code to my Site.css file:

.ui-slider .ui-slider-handle
{
    position: absolute;
    z-index: 2;
    width: 0.5em !important;
    height: 1.2em !important;
    cursor: default;
}

but nothing changed. How can I make jQuery use this css?

Another note: the original css looks like this:

.ui-slider .ui-slider-handle
{
    position: absolute;
    z-index: 2;
    width: 1.2em;
    height: 1.2em;
    cursor: default;
}

So, is css the issue here? Or something else makes my slider stretch??

MORE

This is the generated html:

<div id="slider" class="ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all">
    <div class="ui-slider-range ui-widget-header" style="left: 25.95%; width: 74.05%;">
    </div>
    <a href="#" class="ui-slider-handle ui-state-default ui-corner-all" style="left: 25.95%;">
    </a>
    <a href="#" class="ui-slider-handle ui-state-default ui-corner-all" style="left: 100%;">
    </a>
</div>

At last

I had to override .ui-slider class, not .ui-slider .ui-slider-handle. That was the issue.

Rajesh Rolen- DotNet De, thank you!

horgh
  • 17,918
  • 22
  • 68
  • 123

1 Answers1

1

You can set the width for slider. Change the width and height of jquery slider

.ui-slider .ui-slider-handle {
  position: absolute;
  z-index: 2;
width:1em !important;
height:1em !important;
 cursor: default;
}

http://tycoontalk.freelancer.com/css-forum/200419-jquery-css-slider-width-100-problem.html

Community
  • 1
  • 1
Dr. Rajesh Rolen
  • 14,029
  • 41
  • 106
  • 178