如何在 ASP.NET 中的下拉列表控件中处理长文本 [英] how to handle long text in dropdownlist control in ASP.NET

查看:27
本文介绍了如何在 ASP.NET 中的下拉列表控件中处理长文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
下拉菜单项太宽的建议?

我有一个由数据库填充的下拉列表.它的值字段包含记录的 id,它的选项字段包含记录的文本.但是记录的文本条目很长,使下拉菜单变得如此宽,以至于它完全改变了我网页的外观.当我减少宽度时,它也会减少显示的文本.有什么方法可以使网页看起来不错,并且仍然允许用户查看全文(例如换行、滚动或类似的东西)?

I have a drop down list which is populated by the database. Its value field contains the record's id, and its option field contains record's text. But the record's text entries are very long and make the drop down so wide that it totally changes the appearance of my webpage. When I cut down the width it also cuts down the text displayed. Is there any way I can make the web page look good and still allow the user to see the full text (like wrapping, scrolling, or something like that)?

我该如何处理?

推荐答案

尝试使用 CSS 为下拉列表添加固定宽度,例如:

Try using CSS to add a fixed width to your dropdown, like:

select {width: 150px}

虽然下拉菜单本身的宽度是固定的并且可能不会显示所有文本,但选项元素应该扩展到最宽元素的宽度.

Whilst the dropdown itself will be of a fixed width and may not show all of the text, the option elements should expand to the width of the widest element.

可能无法在 IE7 及更低版本中工作,在这种情况下 此链接可能对这些浏览器有用:

May not work in IE7 and below, in which case the this link may be of some use for those browsers:

这篇关于如何在 ASP.NET 中的下拉列表控件中处理长文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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