简体   繁体   English

旋转jQuery UI滑块无法正常工作

[英]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 我正在申请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 应用css后,滑块无法正确滑动很难拖动手柄内部拖动器没有变形我如何使其平滑

please anyone can help me out 请任何人都可以帮我

JSFIDDLE link JSFIDDLE链接

Why to rotate it if you can change swap and have same effect? 如果可以更改交换并具有相同的效果,为什么还要旋转它? jQuery UI is conflicting with your transform css. jQuery UI与您的transform CSS冲突。

Instead of 代替

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

use 采用

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

    /* removed transform */
}

JSFiddle 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: 有关工作示例,请参见jsfiddler:

https://jsfiddle.net/msully725/ra42v1tf/5/ 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 一旦使用诸如此类的创建事件创建了滑块,就可以简单地添加transform

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

Here is the JSFiddle . 这是JSFiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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