Skip to content

Instantly share code, notes, and snippets.

@LeaVerou
Last active June 3, 2016 09:40
Show Gist options
  • Save LeaVerou/eac6888ebcebc0c756462e8ca7bd32a0 to your computer and use it in GitHub Desktop.
Save LeaVerou/eac6888ebcebc0c756462e8ca7bd32a0 to your computer and use it in GitHub Desktop.
Emulating caret-color in WebKit/Blink
/**
* Emulating caret-color in WebKit/Blink
* Warning: NON-STANDARD. Your text will be shown with the caret color in Firefox, despite the @supports.
*/
@keyframes rainbow {
9% { color: yellow }
27% { color: orange }
45% { color: lime }
63% { color: aqua }
81% { color: blue }
90% { color: fuchsia }
}
textarea {
font-size: 500%;
height: 5em;
color: red;
}
@supports(-webkit-text-fill-color: black) {
/* @supports here doesn't do much, since all browsers have implemented -webkit-text-fill-color
for web compat, but they implemented it incompatibly it seems :( */
textarea {
-webkit-text-fill-color: black;
animation: 10s rainbow infinite; /* Animatable too! */
}
}
<textarea>Click here and notice how the blinking caret is a different color than the text!</textarea>
// alert('Hello world!');
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment