Select option padding not working in chrome
Select option padding not working in chrome
<style>
select option { padding:5px 0px; }
</style>
<select>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
Solution 1:
I just found a way to get padding applied to the select input in chrome
select{
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
padding: 5px;
}
Seems to work in the current chrome 39.0.2171.71 (64-bit) and safari (I only tested this on a mac).
This seems to remove the default styling added to the select input (it also removed the drop down arrow), but allows you to then use your own styling without chrome overriding it.
I stumbled across this fix while using code from here: http://fettblog.eu/style-select-elements/
Solution 2:
This simple hack will indent the text. Works well.
select {
text-indent: 5px;
}
Solution 3:
It seems that
Unfortunately, webkit browsers do not support styling of option tags yet.
you may find similar question here
- How to style a select tag's option element?
- Styling option value in select drop down html not work on Chrome & Safari
The most widely used cross browser solution is to use ul li
Hope it helps!
Solution 4:
I fixed it with this
select {
max-height: calc(1.2em + 24px);
height: calc(1.2em + 24px);
}
max-height: calc(your line height + (top + bottom padding));
height: calc(your line height + (top + bottom padding));