When using Select2, field gets too narrow when there are no options

47
January 01, 2019, at 02:00 AM

When there are no options, the select box shrinks to too narrow width & even "No results found" appears distorted.

Refer fiddle

$('#example').select2({
    placeholder: 'Select a month'
});
<select id="example" multiple="multiple"></select>

Any solutions?

Answer 1

Make use of the width option of select2 as follow :

$('#example').select2({ 
  placeholder: 'Select a month', 
  width: "100%" 
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script> 
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/css/select2.css" /> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.js"></script> 
<select id="example" multiple="multiple"></select>

READ ALSO
How to download tickers from webpage, beautifulsoup didnt get all content

How to download tickers from webpage, beautifulsoup didnt get all content

I want to get the ticker values from this webpage https://wwwoslobors

22
how to pass id from a form in html using nodejs mysql

how to pass id from a form in html using nodejs mysql

Here is the html form through this I can input the client id through the dropdown and I want to use that client id which come from the dropdown to pass through the form:

64
Get Child item from xml document

Get Child item from xml document

I have the following XML document and i am trying to find a way to be able to pass a host name and then get the following host-ip entry for that hostname

45
Need help on collision between 3 moving image objects

Need help on collision between 3 moving image objects

Been having trouble trying to code the collision detection for 3 moving objects, I am aware that it is a rectangle collision that I should be using but it is difficult i need help, I'm not sure on how to use the abs method or any others

52