The select element is hidden behind the text using opacity: 0
and will only be displayed upon clicking. However, I am encountering an issue with unwanted padding on the top and bottom of the list in IE11 on Windows 8:
https://i.sstatic.net/73yjO.png
This padding is a result of the changed height of the select element. I need the select element to be as tall as the text in order to open it by click. Is there a way to reduce the select element's height and still open it with JavaScript?
Here is a sample code snippet:
div {
line-height: 50px;
font-size: 30px;
position: relative;
width: 300px;
}
select {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
display: block;
height: 100%;
width: 100%;
position: absolute;
top: 0;
opacity: 0;
}
<div>
<select name="test" id="test">
<option>Lorem</option>
<option>Ipsum</option>
<option>Dolor</option>
<option>Sit</option>
<option>Amet</option>
</select>
<span>Open select</span>
</div>
The same issue arises with the jQuery-Customselect-Plugin, which utilizes a similar approach:
https://i.sstatic.net/nBDjy.png
I have also reported this issue on the plugin's GitHub page: https://github.com/adamcoulombe/jquery.customSelect/issues/110