Limit Initial width of select list

前端 未结 6 1121
春和景丽
春和景丽 2021-01-12 20:17

I have a select list, where some clients have entered insanely long options for them, which breaks the design. I\'m wondering if there is a way to set a fixed width on the s

6条回答
  •  悲哀的现实
    2021-01-12 20:32

    Since you don't specify what browser support you need, this may or may not be a solution. This works in most browsers IE9+

    select {
        width: 100%;
        max-width: 150px;
    }
    

    Short and sweet. When expanded, the select will display the whole text (unless it exceeds the viewport!).

提交回复
热议问题