私の好みの解決策は、select2
それらを割り当てるのをやめwidth
て、自動化することです。に次のコメントを付けますselect2.full.js
。
コンテナの場合:
Select2.prototype._placeContainer = function ($container) {
$container.insertAfter(this.$element);
//##!!
/*
var width = this._resolveWidth(this.$element, this.options.get('width'));
if (width != null) {
$container.css('width', width);
}*/
};
コンテナ内を検索する場合:
Search.prototype.resizeSearch = function () {
//##!!
/*
this.$search.css('width', '25px');
var width = '';
if (this.$search.attr('placeholder') !== '') {
width = this.$selection.find('.select2-selection__rendered').innerWidth();
} else {
var minimumWidth = this.$search.val().length + 1;
width = (minimumWidth * 0.75) + 'em';
}
this.$search.css('width', width);
*/
};
return Search;
});