jquery.customSelect
jquery.customSelect copied to clipboard
Dropdown doesn't open when adding pseudo elements in css
I wanted to add an arrow in css using :after. When I click the arrow, the dropdown doesn't open. Clicking anywhere else works as expected. Thanks
I'd say that your problem is that your psuedo element is above the transparent
In case this helps anyone else, here's my solution for this:
-
Wrap the
selectin a newdiv:<div class="customSelectContainer"> <select> ... </select> </div> -
Then add these styles:
.customSelectContainer { position: relative; } .customSelectContainer:before { content: "\25BE"; height: 20px; line-height: 1; margin-top: -10px; position: absolute; right: 0; text-align: center; top: 50%; width: 40px; z-index: 2; } .customSelectContainer:after { background-color: #eee; border: #aaa solid 1px; bottom: 0; content: ""; position: absolute; right: 0; top: 0; width: 38px; z-index: 1; } .hasCustomSelect { z-index: 3; }