Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Width Problem #1162

Closed
alexfrancavilla opened this issue Apr 25, 2013 · 9 comments
Closed

Width Problem #1162

alexfrancavilla opened this issue Apr 25, 2013 · 9 comments
Labels

Comments

@alexfrancavilla
Copy link

Hi, when I use chosen on a select field like this:

<select id="mySelect" style="width: 65.935%;" multiple>

Chosen generated the <ul class="chzn-choices"> with a width of 65.935 pixels instead of percent. For the moment I've hacked it with this initialization here

$('#inputNewRecipient').chosen().next().css('width', '65.9574%');

Kind regards

@stof
Copy link
Collaborator

stof commented Apr 25, 2013

Are you using the latest version of Chosen ?

And which browser are you using ? And which version of Chosen (jQuery or Prototype) ?

@alexfrancavilla
Copy link
Author

Sorry for forgetting all this - was a bit in a hurry!
Chosen version is up2date (0.9.13), jQuery Version, Browser is the newest Firefox @ Ubuntu 10.04.
I've just retested it and it turned 65.5% to 55.5px, by the way I'm using Bootstrap.

@pfiller
Copy link
Contributor

pfiller commented Apr 25, 2013

There isn't a great way to rely on style / css for getting the user-defined width (modern browsers return the actual width instead) which means that Chosen automatically ends up with a pixel value. We don't want to be forced to do a re-calculation on screen resize, so we provided an optional interface for percentage widths.

$('#inputNewRecipient').chosen({ width: '65.9574%' });

@pfiller pfiller closed this as completed Apr 25, 2013
@alexfrancavilla
Copy link
Author

@pfiller I am now using the chosen interface to set the width. Now my placeholder text got cut off by the generated width: 55px, is this an issue with chosen?

bug

@pfiller
Copy link
Contributor

pfiller commented Apr 26, 2013

Chosen will make the input field as big as it can within its container. Sometimes that means the placeholder text gets cut off. If you want the text to fit in Chosen, you need to make Chosen at least that big.

I did notice a small issue while investigating this. Basically, the field can be allowed to grow larger than the container in certain cases. See: #1167

@alexfrancavilla
Copy link
Author

The Box was around 600px wide and the placeholder text got cut off after around 6-7 letters.

@netbrain
Copy link

I'm having the same issue.

2013-12-10--1386684424_559x48_scrot

I've set the width property of chosen to a percentage (33%), and then this happens.

Worked around the issue by overriding these css styles:

... li.search-field{
width: 100%;
}

... li.search-field input.default{
width: auto !important;
}

@Gulshan-Doorgah
Copy link

Had similar issue also:
Overriding the following styles worked for me:

li.search-field{
width: 100%;
}
li.search-choice + li.search-field{
width: 20%;
}

@danielmahadi
Copy link

This fixed the issue for me

li.search-field{
width: 100% !important;
}
li.search-field input.default{
width: 100% !important;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants