开发者

Asp.net dropdownlist cut off in IE

开发者 https://www.devze.com 2023-02-22 16:54 出处:网络
I have a asp:DropDownList with fixed width of 150px, but its list items are not enough to fit in 150px width, so it get cut off in IE (works fine in other browsers)

I have a asp:DropDownList with fixed width of 150px, but its list items are not enough to fit in 150px width, so it get cut off in IE (works fine in other browsers) I search about this, but only got sol开发者_StackOverflowution for html SELECT.


set a css class for your dropdownlist and then set width to that css class

<style>
   .myDropDown
   {
       width : 150px;
   }
</style>

<asp:DropDownList CssClass="myDropDown"></asp:DropDownList>

EDIT

so you must remove width attribute from your dropdownload. then it will be resized depending on items size.


<script type='text/javascript'> 

function SetWidthToAuto(drpLst) {
drpLst.style.width = 'auto';
}

function ResetWidth(drpLst) {
drpLst.style.width = '150px';
}
</script>

<div style="width:150px;overflow:hidden;">
<select id="drpTechnology" style='width:150px' onchange='ResetWidth(this)' onblur='ResetWidth(this)' onmousedown='SetWidthToAuto(this)'>
<option value="-1">Browse me..</option>
<option value="1">Short Option</option>
<option value="2">Little bigger than short Option</option>
<option value="3">Largest option available with this select box</option> </select> <div>
0

精彩评论

暂无评论...
验证码 换一张
取 消