动态调整下拉列表的大小.....? [英] Dynamically adjusting the size of a drop-down list .....?

查看:79
本文介绍了动态调整下拉列表的大小.....?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我已将3个项目添加到DropDownList(印度,
新西兰,
美利坚合众国)

如何根据选择动态调整DropDownList的大小.
请帮帮我

在此先感谢

Hi,



I have added 3 items to DropDownList (India,
New Zealand,
United States of America)

How to resize DropDownList dynamically based on selection..?

Please help me

thanks in advance

推荐答案

简单来说,就是不要提供下拉菜单的"width"属性.

它会自动处理它,并将按照其中的值设置宽度.

更新:
正如Ankur所指出的,我建议的是基于其中的最大长度值使宽度下降.但是,听起来问题是要根据下拉菜单中的选定"值在运行时调整宽度.如果是这样,您将不得不使用其他人建议的Javascript.但是,我不建议您采用这种行为,因为在运行时在选择时具有大小可变的控件很烦人,并且不被认为是一种好的UI设计.
Simply, just don''t provide the ''width'' property of the dropdown.

It will automatically take care of it and will set the width as per the values in it.

UPDATE:
As Ankur pointed out, what I have suggested is for having a dropdown of width based on the maximum length value in it. But, sounds like the question is to adjust the width at runtime based on the ''selected'' value in dropdown. If so, you would have to use Javascript as suggested by others. BUT, I would not recommend this behavior as having a varying sized control at runtime on selection is irritating and is not considered a good UI design.


您应该尝试使用javascript或jquery.

找到所选项目文本的宽度(以像素为单位),并将其设置为下拉菜单的宽度.
You should try javascript or jquery.

Find the width of the selected item text in pixel and set it to dropdown''s width.


这篇关于动态调整下拉列表的大小.....?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆