Skip to content

Instantly share code, notes, and snippets.

@germsvel
Last active February 15, 2018 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save germsvel/b0907ea4804389b2d13296eb42532244 to your computer and use it in GitHub Desktop.
Save germsvel/b0907ea4804389b2d13296eb42532244 to your computer and use it in GitHub Desktop.

Styling a select tag can be difficult.

Here are some styles that make it okay looking without having to resort to turning it into a ul and using js to handle interaction.

<span class="custom-dropdown">
  <select class="custom-dropdown__select">
    <option value="option1">Option 1</value>
    <option value="option2">Option 2</value>
    <option value="option3">Option 3</value>
  </select>
</span>
.custom-dropdown {
  background-color: $base-background-color; // white
  border: $base-border; // 1px solid #ccc
  border-radius: $base-border-radius; // 3px
  display: inline-block;
  margin: 0;
  overflow: hidden;
  padding: 0;
  position: relative;
  vertical-align: middle;

  &::after {
    content: '\25BC';
    font-size: $xxxs-font-size; // 14px
    line-height: $solid-line-height; // 1
    margin-top: -.5em;
    position: absolute;
    right: 1.2em;
    top: 50%;
  }

  &:focus {
    outline: none;
  }
}

.custom-dropdown__select {
  -moz-appearance: none;
  -webkit-appearance: none;
  appearance: none;
  background-color: transparent;
  border: 0;
  padding-left: .5em;
  padding-right: 1.5em;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment