How do I adjust the width of a DropDown <select

2019-06-19 12:42发布

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?

标签: html xhtml
4条回答
倾城 Initia
2楼-- · 2019-06-19 13:28

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楼-- · 2019-06-19 13:33
<style type="text/css">     
    select {
        width:200px;
    }
</style>

Does that not work?

查看更多
forever°为你锁心
4楼-- · 2019-06-19 13:37

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.

查看更多
唯我独甜
5楼-- · 2019-06-19 13:45

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

查看更多
登录 后发表回答