Select option padding not working in chrome
When padding falls flat in <option> elements in Chrome, jQuery select2 plugin comes to the rescue. It offers a dropdown with styles that bypass browser limitations:
Style .select2-style class in CSS with desired padding, and Chrome will display your chic dropdown.
When browsers play tough
Chrome, in particular, has a different manifesto to follow - it uses its own styles (a.k.a user agent stylesheet) over custom ones, curtailing customization of elements like option.
Even with notorious -webkit-appearance: none;, -moz-appearance: none;, or appearance: none; CSS trickery, the browser stands its ground, resisting padding on <option> elements.
Styling options for select elements
Dressing up the dropdown arrow
Chrome allows you to go wild with the styles of the dropdown arrow - just use -webkit-appearance: none; on <select> and put on your creativity hat:
The sneaky indent padding trick
Don't present. Pretend. Apply text-indent: 5px; on <select> for a faux padding effect:
Swapping <select> and <option> with ul and li
To obtain a uniform look across browsers, swap <select> and <option> with ul and li. Then put JavaScript to work for managing the selection states.
The font size twist
Give some space to <option> elements by tweaking the font-size. It simulates padding and leaves more room for interaction:
Crafting pseudo-padding with height
Manipulating the height of <select> with calc offers the illusion of vertical padding:
Handling the quirks
Playing with font size
font-size-adjust: 0.3 combined with font-size: 2em keeps the visual size of <option> elements stable, ensuring cross-browser consistency.
Embracing Webkit limitations
Understand that Chrome and other Webkit browsers pose styling constraints on <option> tags. Primarily, you only get a free hand with font styles. Patience is key!
Was this article helpful?