Skip to content

Instantly share code, notes, and snippets.

@carlos-sanchez
Created November 13, 2013 03:11
Show Gist options
  • Save carlos-sanchez/7443059 to your computer and use it in GitHub Desktop.
Save carlos-sanchez/7443059 to your computer and use it in GitHub Desktop.
Replace text with CSS We could use The Checkbox Hack here to make the text swap entirely CSS. The replacement happens the exact same way, it just happens when an invisible checkbox right before the word is either :checked or not. This means the word needs to be in a label as well, which is able to toggle that checkbox’s state through the for att…
#example {
  position: relative;
}
#example-checkbox {
  display: none;
}
#example-checkbox:checked + #example:after {
  content: "Hide";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: white;
}
<input id="example-checkbox" type="checkbox">
<label for="example" id="example">Show</label>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment