简体   繁体   中英

Rotating jquery UI slider does not work properly

I am creating slider as below

$("#slider1V").slider({orientation : "vertical",min : 0,max : 100});

i am applying css

#slider1V {
  -ms-transform: rotate(90deg); /* IE 9 */
  -webkit-transform: rotate(90deg); /* Safari */
  transform: rotate(90deg);
}

after applying css the slider does not slide properly Its very hard to drag the handle The internal dragger does not get transformed how can i make it smooth

please anyone can help me out

JSFIDDLE link

Why to rotate it if you can change swap and have same effect? jQuery UI is conflicting with your transform css.

Instead of

#slider1V {
    height: 132px;
    width: 10px;
}

use

#slider1V {
    height: 10px;
    width: 132px;

    /* removed transform */
}

JSFiddle

Split out height/width into their own classes

#slider1V
{
      position: relative;
      left:20%;
      float: left;
      top: 30px;        
 }

.sliderVertical
{
      width: 132px;
      height: 10px;
}

.sliderHorizontal
{
      width: 132px;
      height: 10px;
}

Then for horizontal

$("#slider1V").slider({ orientation: "horizontal" });
$("#slider1V").addClass("sliderHorizontal");

and vertical

$("#slider1V").slider({ orientation: "vertical" });
$("#slider1V").addClass("sliderVertical");

See jsfiddler for working example:

https://jsfiddle.net/msully725/ra42v1tf/5/

Here is the solution for you: Have a look on this fiddle

<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>    
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
    <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    <script>
    $(document).ready(function(){

            $("#slider1V").slider({
            orientation : 'vertical',
                animate: true,
            min : 0,
            max : 100
    });

    });
    </script>
    <div id="slider1V"></div>

You could simply add transform once the slider is created using create event like so

$("#slider1V").slider({
    orientation : "vertical",
    min : 0,
    max : 100,
    create: function( event, ui ) { $(this).css('transform','rotate(38deg)') }
});

Here is the JSFiddle .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM