我喜欢select2的盒子
https://github.com/ivaynberg/select2
我使用format:选项来格式化每个元素,它看起来很棒。
一切都很好,除了选定的元素由于图像而大于选择框的高度。
我知道如何更改宽度,但如何更改高度,以便在选择元素后,它会显示全部内容(大约150px)
这是我的印心:
$("#selboxChild").select2({
matcher: function(term, text) {
var t = (js_child_sponsors[text] ? js_child_sponsors[text] : text);
return t.toUpperCase().indexOf(term.toUpperCase()) >= 0;
},
formatResult: formatChild,
formatSelection: formatChild,
escapeMarkup: function(m) {
return m;
}
});
这是我的选择框
No child attached
需要说明的是:我不希望每个选项的高度发生变化
我正在寻找选择框,以便在您选择子对象后更改高度。
因此,当页面第一次加载时,它会显示“没有选择孩子”,当您单击下拉菜单并选择一个孩子时,您会看到孩子的图像。现在我需要选择框来展开!否则孩子的照片就会被剪掉。
有人明白吗?
发布于 2017-01-24 22:39:44
您应该将以下样式定义添加到CSS中:
.select2-selection__rendered {
line-height: 31px !important;
}
.select2-container .select2-selection--single {
height: 35px !important;
}
.select2-selection__arrow {
height: 34px !important;
}
发布于 2013-03-28 04:12:37
你可以用一些简单的css来做这件事。据我所知,您希望使用类"select2-choices“设置元素的高度。
.select2-choices {
min-height: 150px;
max-height: 150px;
overflow-y: auto;
}
这应该会给你一个150px的设置高度,如果需要的话,它会滚动。只需简单地调整高度,直到您的图像适合您的期望。
您还可以使用css来设置select2结果的高度( select控件的下拉部分)。
ul.select2-results {
max-height: 200px;
}
200px是默认高度,因此请将其更改为所需的下拉列表高度。
发布于 2013-09-02 10:45:02
您可能希望首先为select2提供一个特殊的类,然后只修改该类的css,而不是在站点范围内更改所有的select2 css。
$("#selboxChild").select2({ width: '300px', dropdownCssClass: "bigdrop" });
SCSS
.bigdrop.select2-container .select2-results {max-height: 200px;}
.bigdrop .select2-results {max-height: 200px;}
.bigdrop .select2-choices {min-height: 150px; max-height: 150px; overflow-y: auto;}
https://stackoverflow.com/questions/14824676
复制相似问题