How do I adjust the width of a DropDown <select> box?

拈花ヽ惹草 提交于 2019-12-08 19:14:01

问题


I need to adjust the width of a select HTML box without using css, is there a way? I tried size but then it's adjusting the height, and width does nothing? Is there another way?


回答1:


<style type="text/css">     
    select {
        width:200px;
    }
</style>

Does that not work?




回答2:


There is no way to do it in pure HTML as per http://www.w3.org/TR/html401/interact/forms.html#h-17.6. You can set it using the style element, though which is kind of without css in that it is inline.

<select style="width: ....



回答3:


Add an empty option with enough spaces in it ...




回答4:


If u using jquery, Maths Physics Chemistry

This is my select html code. So u have to add another div which contains jquery class name including your class name and apply height and width in your class.

<div class="ui-select selBox"> 
    <select>
    <option>Maths</option>
    <option>Physics</option>
    <option>Chemistry</option>
    </select>
</div>
.selBox{
 width: 470px !important;
 height: 40px !important;
}

here selBox is my class name and ui-select is jquery class name.



来源:https://stackoverflow.com/questions/1411484/how-do-i-adjust-the-width-of-a-dropdown-select-box

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!