Skip to content

Instantly share code, notes, and snippets.

@shelldandy
Created February 22, 2017 05:41
Show Gist options
  • Save shelldandy/74afe372486c760681ae9ab2892117e8 to your computer and use it in GitHub Desktop.
Save shelldandy/74afe372486c760681ae9ab2892117e8 to your computer and use it in GitHub Desktop.
Bullet proof custom selects with css only
$caret: url(BASE_64_PNG);
.custom-select {
appearance: none;
border-radius: 0; // Safari Mac/iOS
border: none; // Safari Mac/iOS/Firefox
display: block;
width: 100%;
background: {
size: 12px; // Size of your caret
repeat: no-repeat;
position: 95% 50%; // X-axis Y-axis
image: $caret; // Base64 for IE
}
&::-ms-expand { // IE
display: none;
}
&:-moz-focusring { // Firefox
color: transparent;
text-shadow: 0 0 0 #000;
}
}
@shelldandy
Copy link
Author

Designers sure love their custom selects and after tons of experimenting this is a really cross-browser solution with css-only.

Remember to pass this file through autoprefixer as usual

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment