简体   繁体   English

jQuery / Javascript旋转下拉菜单

[英]Jquery/Javascript for rotating a dropdown menu

I need a dropdown menu to appear rotated 90 deg anticlockwise - so that the dropdown select "button" text appears vertically, and then the options slide out likewise in a rotated, sideways way, with vertical text. 我需要一个下拉菜单来显示逆时针旋转90度-以便下拉选择“按钮”文本垂直显示,然后选项也以垂直文本旋转,横向倾斜地滑出。 (Context: The user needs to select a title from a number of options for the Y axis of a graph - and the dropdown needs to exist where the title will finally go, likewise rotated.) (上下文:用户需要从图形的Y轴的多个选项中选择一个标题-并且下拉菜单必须存在标题最终将要旋转到的位置,同样旋转)。

html currently simply as follows: html当前简单如下:

<select id="title"  >
<option value="title-0">Choose a chart title</option>
<option value="title-1">title 1</option>
<option value="title-2">title 2</option>
<option value="title-3">title 3</option>
</select>

I know there is CSS3 stuff for this. 我知道有CSS3的东西。 I've referred already to: Need Jquery code for rotate a whole div So I've tried CSS like so, or similar: 我已经提到过: 需要Jquery代码来旋转整个div因此,我尝试过CSS或类似方法:

.box_rotate {
-webkit-transform: rotate(90deg);  /* Saf3.1+, Chrome */
-moz-transform: rotate(90deg);  /* FF3.5+ */
-ms-transform: rotate(90deg);  /* IE9 */
-o-transform: rotate(90deg);  /* Opera 10.5 */
transform: rotate(90deg);  
filter: progid:DXImageTransform.Microsoft.Matrix(/* IE6–IE9 */ 
M11=6.123233995736766e-17, M12=-1, M21=1, M22=6.123233995736766e-17, sizingMethod='auto expand');
zoom: 1;
}

What happens is - at least in Firefox 15 - the select "button" gets rotated, but the dropdown options, when the menu is activated, remain in the horizontal position they would otherwise be - (and the dropdown links don't work). 发生的事情是-至少在Firefox 15中-旋转了选择的“按钮”,但下拉菜单选项被激活时,下拉菜单选项仍保持水平位置(否则下拉链接将不起作用)。

I have tried applying the rotate class separately to the option tags, or to the select tag, or to an all-enclosing div. 我尝试将rotate类分别应用于选项标签,选择标签或全封闭div。 None of that seems to fix things. 这些似乎都无法解决问题。

There are, apparently, "a lot of plugins that are able to add rotate support to jQuery." 显然,“有许多插件可以向jQuery添加旋转支持”。 (according to previously mentioned SO question). (根据前面提到的SO问题)。 The one's I've seen just seem to apply to images or simple div elements - nothing that actually works for a whole dropdown menu. 我见过的那个似乎只适用于图像或简单的div元素-实际上对整个下拉菜单没有任何作用。

Any ideas? 有任何想法吗? .. A Javascript/jquery solution would be prefered. ..最好使用Javascript / jquery解决方案。

Thanks 谢谢

这是一个浏览器错误: https : //bugzilla.mozilla.org/show_bug.cgi?id=455164

it seems it works on FX15 when the rotation effect is applied to an optgroup element, 将旋转效果应用于optgroup元素时,它似乎可以在FX15上使用,

http://jsbin.com/ifatiy/1/edit http://jsbin.com/ifatiy/1/edit

<select>
    <optgroup>
       <option value="title-0">Choose a chart title</option>
       <option value="title-1">title 1</option>
       <option value="title-2">title 2</option>
       <option value="title-3">title 3</option>
    </optgroup>
</select>

but you may need to also specify an height (and reset the style introduced with optgroup) 但您可能还需要指定一个高度(并重置optgroup引入的样式)

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

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