我正在使用 select2并希望在展开时强制它显示所有可用选项,而不是添加滚动条。
现在它在选项区域内有一个滚动条:http://screencast.com/t/fYKPArqz5f
那可能吗?
最佳答案
你可以更新 select2.css 中的 CSS,大概是第 302 行:
/* results */
.select2-results {
/* max-height: 200px; comment out the max-height! */
padding: 0 0 0 4px;
margin: 4px 4px 4px 0;
position: relative;
overflow-x: hidden;
overflow-y: auto;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
或者,如果您无权访问 CSS,或者不想在您的网站上进行一般更改,您可以在您自己的样式表中覆盖特定样式:
.select2-results {
max-height: none;
}
看到这个 JSFiddle
关于jquery-select2 - 强制 select2-plugin 显示所有项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19938538/