Assign height property to option tag

此生再无相见时 提交于 2020-01-15 05:56:21

问题


I need to set a bigger height for the option tags inside my select.

<select name="forms" id="forms">
    <option value="1">Row 1</option>
    <option value="1">Row 1</option>
    <option value="1">Row 1</option>
</select>

I used the CSS code below for this purpose, but it did not work.

option {
   padding-top:5px;
   padding-bottom:5px;
}

Also I have tested this one, and again, anything happened.

option {
    height:20px;
}

What is your suggestions ?


回答1:


The implementation of select often uses built-in routines that are immune to CSS. This is why both methods fail on many browsers. On Firefox, they both work. The same seems to apply to any indirect methods one might try (line-height, font-size).




回答2:


I could set a certain height for it using a style for the select tag:

<select name="" style="height:25px">


来源:https://stackoverflow.com/questions/8534104/assign-height-property-to-option-tag

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