This is a migrated thread and some comments may be shown as answers.

Stretch slider to take whole width

4 Answers 1076 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Anirban
Top achievements
Rank 1
Anirban asked on 12 Apr 2012, 11:52 PM
Is there any style available to make the slider take the entire div width. I have set the div width = 100% . Tried to put a style to the div and also tried to keep the div width to 500px with no much luck. I have tried to use the following style as well: 

       .k-slider .k-slider-horizontal
         {
             width: 400px; 
         }

Here is the slider code : 

             $("#slider").kendoSlider({
                 min: 1990,
                 max: 2010,
                 orientation: "horizontal",
                 smallStep: 1,
                 largeStep: 5,
                 tickPlacement: "bottomRight",
                 showButtons: false
             });

Am I missing something ? 

Please suggest.

Thanks

4 Answers, 1 is accepted

Sort by
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 01 May 2012, 08:39 PM
@Telerik I'd also like to know the answer please, was just about to post on this :)
0
Anirban
Top achievements
Rank 1
answered on 02 May 2012, 12:15 AM
Okay, I found the solution to it .. Here the css code change that you need to do.. 

.k-slider-horizontal

        {

            display: inline-block;

            float: left;

            width: 650px; <!-- set the width as 100%-->

            height: 26px;

            margin-right: 500px;

        }
Hope this helps

Regards,
Anirban


0
John
Top achievements
Rank 1
answered on 19 Oct 2012, 03:33 PM
Thanks for the fix.  Is there anyway to make this also handle screen resizing?
1
JohnVS
Top achievements
Rank 1
answered on 18 Sep 2014, 07:15 PM
For anyone coming around to this post years later, like I did, you can update the width of a Slider by using this code from the documentation:

$(document).ready(function() {
    $("#slider").kendoSlider();
    var slider = $("#slider").getKendoSlider();
    slider.wrapper.css("width", "400px");
    slider.resize();
});

As far as John's question about screen resizing, you could always wrap this code inside a window resize event listener:

$(window).on('resize', function () {
    var sliders = $("[data-role='slider']");
    sliders.each(function (index, ele) {
        var slider = $(ele).getKendoSlider();
        slider.wrapper.css("width", "100%");
        slider.resize();
    });
});
Tags
Slider
Asked by
Anirban
Top achievements
Rank 1
Answers by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Anirban
Top achievements
Rank 1
John
Top achievements
Rank 1
JohnVS
Top achievements
Rank 1
Share this question
or