html - 选择下拉宽度 - Chrome 问题

标签 html google-chrome css drop-down-menu width

我想控制<option>列表宽度 <select>落下。默认情况下,浏览器计算 <option> 中较大的文本和住宿下降。它在网站上看起来不太好。我尝试了以下 CSS 片段并发现在 FF 中工作。

select{
    width : 120px;
}
select option {
    width : 90px;
}

唯一的麻烦是 Chrome。如果有任何解决方法,您能否告诉我。

Demo

最佳答案

我用谷歌搜索没有结果。我只遗漏了脚本选项。下面的代码可以解决这个问题..

/* 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);
    }

Updated Demo

关于html - 选择下拉宽度 - Chrome 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15239730/

相关文章:

javascript - 在 jquery 弹出窗口中禁用背景

html - Chrome 的自动填充隐藏文本输入的背景图片

javascript - 背景在谷歌浏览器的选择输入字段内不起作用

css - Bootstrap Navbar 中间有品牌

google-chrome - 重新启用扩展安装

Jquery 在点击时在两个文本变量之间切换

javascript - 选择 select bootstrap 在 bootstrap 模式中显示两次

html - 表格单元格高度 - 是否也有一些必须遵守的最小尺寸?

javascript - 如果鼠标下的元素只有 "overflow-y: scroll"并且水平滚动,iOS Safari 似乎永远不会触发滚动事件

Javascript Google Chrome 扩展,寻找域名,而不是应用程序 ID