简体   繁体   English

Jquery Mobile - 如何覆盖选择框的高度和宽度。

[英]Jquery Mobile — how to Override Height and width of select box.

<select id="selectId" name="name1" style="height:10% !important;" >
    <option>Select One</option>
    <option>xxx</option>
    <option>yyy</option>
    <option selected="selected">rrr</option>
    <option>ggg</option>
    <option>fff</option>
    <option>qqq</option>
</select>

How can i set the width and height for select. 如何设置选择的宽度和高度。 I am using jquery mobile css and i am unable to make this work. 我正在使用jquery mobile css,我无法完成这项工作。 please help me 请帮我

Thanks in advance 提前致谢

You need to change this css class .ui-select try this: 你需要改变这个css类.ui-select试试这个:

.ui-select{
  width:200px;
  height:70px;
}

Check the Demo 检查演示

If you want to affect only that select use the id to target that like this in Jquery: 如果你只想影响那个选择使用id在Jquery中这样定位:

$(document).ready(function(){
  $('#selectId').closest('.ui-select').addClass('select_small')
})

With this you can add this class: 有了这个你可以添加这个类:

.select_small{
  width:200px;
  height:70px;
}

Check another DEMO 检查另一个DEMO

Try specifying exact height such as 100px, or if you want it to be with percentage, make sure your container has height as well. 尝试指定精确的高度,例如100px,或者如果您希望它具有百分比,请确保您的容器也具有高度。

<select id="selectId" name="name1" style="height:100px !important;" >

http://jsfiddle.net/F2952/ http://jsfiddle.net/F2952/

this runs. 这个运行。

If you insist on using jquery for this you can use 如果你坚持使用jquery,你可以使用

$("#selectId").width("enter your width");
$("#selectId").height(enter your height);

The height of select seems to be dependent on the options . select的高度似乎取决于options So, I would style it like: 所以,我会像它样式:

select option{height:50px}

Demo here . 在这里演示

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

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