Does the select
tag allows to use the :after
selector in order to create a pseudo element after it?
I've tried on Chrome, Safari and Firefox on Mac and it doesn't seem to work.
Does the select
tag allows to use the :after
selector in order to create a pseudo element after it?
I've tried on Chrome, Safari and Firefox on Mac and it doesn't seem to work.
Here is a compromise that I have used. http://jsfiddle.net/pht9d295/3/
And CSS
Well, it looks like the
select
tags doesn't allow:after
or:before
pseudos because they are customized by each vendor, so it's quite hard to modify them and that's because they don't allow:before
or:after
pseudo elements on them.To everyone who sees this, there's a good option to create a custom
select
element with jQuery and minimal modification… Create a select and then use jQuery to edit it:http://jsfiddle.net/tovic/ZTHkQ/
This is a modern solution I cooked up using font-awesome. I'm not sure how cross-browser friendly it is. Vendor extensions have been omitted for brevity.
HTML
SCSS
If your select element has a defined background color, then this won't work as this snippet essentially places the Chevron icon behind the select element (to allow clicking on top of the icon to still initiate the select action).
However, you can style the select-wrapper to the same size as the select element and style its background to achieve the same effect.
Check out my CodePen for a working demo that shows this bit of code on both a dark and light themed select box using a regular label and a "placeholder" label and other cleaned up styles such as borders and widths.