我正在尝试在我的 html 中使用 Bootstrap 使用多个 select2 选择表单。但是我在调整大小方面遇到了问题,select2 框不能与网格一起使用,而且它还会咕噜咕噜地显示下一个元素的大小。 HTML
<div class="select2-container col-md-11">
<select class="form-control s2" id="complaint" multiple="multiple" name=
"complaint[]">
<option value="bad_breath">
Bad Breath
</option>
<option value="bleeding_gum">
Bleeding Gum
</option>
<option value="swollen_gum">
Swollen Gum
</option>
<option value="gum_pain">
Gum Pain
</option>
<option value="loose_teeth">
Loose Teeth
</option>
<option value="sensitive_teeth">
Sensitive Teeth
</option>
<option value="darkened_teeth">
Darkened Teeth
</option>
<option value="damaged_teeth">
Damaged Teeth
</option>
</select>
</div>
JS
<script type="text/javascript">
$(".s2").select2({
closeOnSelect: false
});
$(document).ready(function() {});
最佳答案
首先在您的选择框中添加:<select data-width="100%"></select>
在标题中添加此 JS 和 CSS :
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.2/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.2/js/select2.min.js"></script>
关于javascript - select2 bootstrap 大小问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36867586/