Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to fix the width of drop down list?

Here is what I got:

<select id="box1">
   <option>ABCDEFG</option>
</select>  

<select id="box2">
   <option>ABCDEFGHIJKLMNO</option>
</select>

I have 2 different Drop Down lists. Since the width of a drop down list depends on the width of the longest text in the option, I end up with 2 drop down lists with 2 different widths. This makes my webpage look goofy.

What I want is to set it so that both of my drop down lists will have the same width (I'd prefer the width to be very long, so that even the longest item won't be truncated).

like image 638
Thang Pham Avatar asked Mar 08 '10 21:03

Thang Pham


People also ask

How do you change the width of a drop-down list?

Tip: If you want the width of the dropdown content to be as wide as the dropdown button, set the width to 100% (and overflow:auto to enable scroll on small screens). Instead of using a border, we have used the CSS box-shadow property to make the dropdown menu look like a "card".

How do I fix dropdown size?

Widening Drop-down Lists The length of the drop-down box is not big enough to display the entire text. The simple solution is to widen the column that the drop-down box is in. You can adjust the column manually by dragging the border of the column header.

Why is data validation list so wide?

In most cases: the worksheet had other cells with data validation in the same row. all dropdowns became the width of the widest dropdown. one of the data validation lists is in a merged cell.


1 Answers

Length referring to number of options visible?? If that is the case use size. Here is the documentation. Let me know if you mean any different.

After EDIT: Set the width for the select. But it would be hard to set width to show only particular length. Second Edit: You can't do that using CSS, you got to use javascript. On every change of the select, you have to see which of the two elements has maximum width and set the same to the other.

like image 138
Teja Kantamneni Avatar answered Oct 13 '22 00:10

Teja Kantamneni