我在我的页面中有一个selectpicker(bootstrap),其中的选项正在加载。它有很多列表,但不好看。我想减少selectpicker的高度。我已经提供了内联风格和所有内容,但并不反映。如何调整selectpicker下拉菜单的高度
这是我的代码
<select class="selectpicker" data-dropup-auto="false" id="estType" name="estType">
<option selected disabled value="0">Select</option>'
</select>
我的js代码
$function ({
$.ajax({
datatype: "json",
type: "GET",
async: false,
url: "Establishment/GetPrePopulationDetails",
success: function (result, success) {
var esttypes = $.map(result['EstablishmentTypes'],
function (key, value) {
return $('<option>', { value: value, text: key });
});
$('#estType').append(esttypes);
},
error: function (xhr, ajaxOptions, thrownError) {
console.error(xhr.status);
console.error(thrownError);
}
});
});
参考http://stackoverflow.com/questions/21111652/how-do-you-set-the-max-height-of-an-expanded-chosen-element-jquery-plugin – Ish
使用'max-height'为了那个原因。我个人的选择是使用媒体查询,并且对桌面型设备具有“px”最大高度,对于移动设备具有“vh”值。另外,如果您有超过20个孩子,请考虑使用[select2](https://select2.github.io/)或[autocomplete](https://jqueryui.com/autocomplete/)解决方案。 –