0

How set height for select? i need that "select" it height less popup height. I found some more solution with use js but this code is bad. enter image description here

  • **[Please share your code with us](http://stackoverflow.com/help/mcve)**, in russian: **[Как задавать вопросы](http://ru.stackoverflow.com/help/mcve)** – AGE Jan 04 '16 at 18:42
  • @AGE It is unnecessary – Konstantin Kulakov Jan 04 '16 at 18:44
  • @iamnotmaynard attribute size in this case not work. – Konstantin Kulakov Jan 04 '16 at 18:45
  • Right, I get what you mean. – Reinstate Monica -- notmaynard Jan 04 '16 at 18:45
  • 2
    Possible duplicate of [Height of an HTML select box (dropdown)](http://stackoverflow.com/q/570642/1046690) – AGE Jan 04 '16 at 18:47
  • @iamnotmaynard I want the drop-down list does not extend outside the popup window. You understand me? – Konstantin Kulakov Jan 04 '16 at 18:48
  • 1
    @AGE this not duplicate. Top answer in "http://stackoverflow.com/q/570642/1046690" is obsolete. Link to JSFiddle is corrupted – Konstantin Kulakov Jan 04 '16 at 18:51
  • @KonstantinKulakov updated my answer – Ahmad Alfy Jan 04 '16 at 18:51
  • @AhmadAlfy test it please https://jsfiddle.net/dLbtxj0v/ – Konstantin Kulakov Jan 04 '16 at 18:52
  • It's not possible using a regular – Jeff Jan 04 '16 at 18:54
  • @KonstantinKulakov the reason why I believe it is a duplicate is because adding `size` to the select box will eliminate the drop down, if you want to have a drop down and a custom height on it, you need to develop your own custom select element... which is exactly what **jlbruno** wrote at the same time I wrote this. – AGE Jan 04 '16 at 18:55
  • @AGE I was his last answer, I showed the result of adding size. It does not correspond to my expectations – Konstantin Kulakov Jan 04 '16 at 18:57
  • Try the second answer to [this question](http://stackoverflow.com/questions/13362484/max-height-for-select-element-dropdown-option-elements/13362562#13362562). See https://jsfiddle.net/fdqfytsr/ and adjust to taste. – Reinstate Monica -- notmaynard Jan 04 '16 at 18:59
  • @KonstantinKulakov one approach to doing your own custom select box is to use jQuery UI as shown in this example: **[How do you set the max height of an expanded “Chosen” element](http://stackoverflow.com/q/21111652/1046690)** – AGE Jan 04 '16 at 19:01
  • @AGE Thanks. This is exactly what I was looking for – Konstantin Kulakov Jan 04 '16 at 19:03
  • @KonstantinKulakov no problem, I will post it as an answer – AGE Jan 04 '16 at 19:03
  • Why isn't [Height of an HTML select box (dropdown)](http://stackoverflow.com/q/570642/1529630) a dupe? It says "Can someone confirm that its not possible to change the height of a dropdown". The answer says: "confirmed". – Oriol Jan 04 '16 at 19:04
  • @Oriol because it is a known fact, perhaps not obvious but it is true if you take a quick look at the docs – AGE Jan 04 '16 at 19:05

1 Answers1

2

First of all understand that native select when expanded is controlled by the web browser, therefore any and all modifications are out of your control.

That being said, you can create your own custom select elements and behavior. One such was is using JQuery UI as specified on this Stack Overflow question: How do you set the max height of an expanded “Chosen” element

For reference on why the native select element behaves the way it does, check this out: Height of an HTML select box (dropdown)

Any more questions regarding this? Please ask in the comments below.

Community
  • 1
  • 1
AGE
  • 3,752
  • 3
  • 38
  • 60
  • 1
    [Chosen](https://github.com/harvesthq/chosen/) is a very good option. I use it on many projects, and always have full control.. height width full colors etc.. – James Walker Jan 10 '21 at 15:57