34

I can't change select height, with all browser working fine, but Safari no, where can be problem? Also I try make class .style select, but not working.

select {
width: 170px; 
height: 25px;
}
idmean
  • 14,540
  • 9
  • 54
  • 83
Wizard
  • 10,985
  • 38
  • 91
  • 165

10 Answers10

37

Try adding this:

-webkit-appearance: menulist-button;
Labokas
  • 585
  • 5
  • 7
  • 2
    Doesn't works with Safari on Windows machine, but Line-Height property is enough to style the height of Select tag – Deepak Yadav Jun 22 '15 at 06:50
  • 1
    This is the only working method since Safari Version 10.1.2. Line height no longer works. – Ahmad Alfy Sep 07 '17 at 12:06
  • This does not work for me, 1/1/2020. I have to set `-webkit-appearance: none;` and use a css hack to add my own drop-down arrow icon – turkinator Jan 03 '20 at 16:59
31

To style a select in Safari, you first have to turn off the os styling:

-webkit-appearance: none;
  • 3
    True, but this will hide the dropdown arrow. Therefore the best option is line-height (see answer above). – Gilad Barner Feb 25 '15 at 09:48
  • 1
    This does hide the drop-down arrow, but it does also successfully strip the offensive styling - clean palette. +1 – David H. Feb 07 '17 at 22:12
  • 1
    This can be useful for those making a stylized select drop down by hiding the original select and having an overlay to look like the styled drop down. – Jeremy Trpka Dec 20 '19 at 12:58
27

You can also use

line-height: 25px

which doesn't affect other browsers, but fixes this bug in Safari

hobailey
  • 861
  • 1
  • 12
  • 22
3
@media screen and (-webkit-min-device-pixel-ratio:0) {
    select {
        -webkit-appearance: menulist-button !important;
        line-height:24px !important;
    }
}

This code ensures the same height across browsers.

David
  • 3,392
  • 3
  • 36
  • 47
3

The best way use modernizer detector and give safari class select menu a

line-height: 20px;

or you can use jquery UI select menu to solve this by another cross-browser wy.

Sanjib Debnath
  • 3,556
  • 2
  • 22
  • 16
2

at least on iPad the select is not rendered for padding or line-height but instead will render given height and center vertically the value

select {
   -webkit-appearance:menu-item; // or menulist-button
   -moz-appearance:menu-item;
   height:2.4em;   // this must be calculated to match other input types     
}

input[type="text"], select {
    min-width:12em;  
    border-radius:5px;
}

the only thing unresolved now is background which is predefined and imutable

bortunac
  • 4,642
  • 1
  • 32
  • 21
1

Nothing worked for me until I used inline style:

<select name="pickupsel" id="pickups" style="line-height:33px">

Somehow Safari (latest Windows version, 5.1.7) doesn't read this style property from CSS file.

Sergey Lost
  • 2,511
  • 3
  • 19
  • 22
1
@media screen and (-webkit-min-device-pixel-ratio:0) { select { -webkit-appearance: menulist-button !important; line-height:24px !important; } }

Give line-height according your requirement.

laaposto
  • 11,835
  • 15
  • 54
  • 71
1

This is how I am solving this in 2022:

select, input {
    font-size: 14px; //or whatever
    height: 3em;
    line-height: 3em;
    padding: 0; //top and bottom must be 0
    -webkit-appearance: none;
}
Mladen Janjetovic
  • 13,844
  • 8
  • 72
  • 82
0

This is how I am solving this in 2022:

    select {
      background-color: inherit;
    }