mardi 14 juin 2016

How to remove unwanted padding on styled select in IE11/Windows 8

The select is hidden behind the text with opacity: 0 and will be opened normally with a click. My problem is, that the options got unwanted padding on top and bottom of the list in IE11 on Windows 8:

enter image description here

The padding comes from the changed height of the select. But I need it as large as the text to open it by click. I don't think there's any opportunity to reduce the select in height and open it with Javascript?

Running example:

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>

Same problem occurs on the jQuery-Customselect-Plugin, which uses the same technique:

enter image description here

Also, I opened an issue on the plugin: https://github.com/adamcoulombe/jquery.customSelect/issues/110

Aucun commentaire:

Enregistrer un commentaire