Skip to content

Instantly share code, notes, and snippets.

@rstacruz
Last active April 13, 2020 19:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rstacruz/ef5fff943b4c0990a8f77f809797909a to your computer and use it in GitHub Desktop.
Save rstacruz/ef5fff943b4c0990a8f77f809797909a to your computer and use it in GitHub Desktop.
CSS Blitz - Form fields

CSS Blitz - Form Fields

css-form-fields

https://codesandbox.io/s/kmmwpyy1m3

What to do:

  • reset margin: 0, padding: 0, border: 0
  • reset font-size: 1em
  • add background and color
  • fixed height, no vertical padding
  • style box-shadow (instead of border)
  • don't style :hover, it can be complicated

What to style:

  • .input
  • .input:hover (optional)
  • .input:focus
  • .input:focus:hover (optional)
  • .input:invalid:not(:focus)
  • .input::placeholder
  • .input:focus::placeholder
  • .input:disabled
  • textarea.input { height: auto; min-height: ...; resize: vertical; }
  • textarea.input { padding-top, padding-bottom }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment