我想控制<option>
列表宽度 <select>
落下。默认情况下,浏览器计算 <option>
中较大的文本和住宿下降。它在网站上看起来不太好。我尝试了以下 CSS 片段并发现在 FF 中工作。
select{
width : 120px;
}
select option {
width : 90px;
}
唯一的麻烦是 Chrome。如果有任何解决方法,您能否告诉我。
最佳答案
我用谷歌搜索没有结果。我只遗漏了脚本选项。下面的代码可以解决这个问题..
/* To trim the charaters in the option list */
var optLen = $('#country option').size();
//console.log("Total length is :" +optLen);
for(var i=0; i<optLen; i++){
var txt = $('#country option').eq(i).text();
//alert(txt);
txt = txt.substring(0,20);
//alert(txt);
$('#country option').eq(i).text(txt);
}
关于html - 选择下拉宽度 - Chrome 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15239730/