27
loading...
This website collects cookies to deliver better user experience
color: rainbow
in CSS, but can still use words to describe certain values in CSS. While numbers allow for very precise values, words are easy to read and easy to keep in mind, so they are ideal for teaching, testing, and demonstration..gradient-container {
background: linear-gradient(
to right,
red, orange, yellow, green, blue, indigo, violet
);
}
.gradient-container {
background: radial-gradient(
at 0% 100%, /* position center to bottom left */
to right,
white 20%, /* color-stop to enlarge white center */
red, orange, yellow, green, blue, indigo, violet,
white 50% /* color-stop to enlarge white outside */
);
}
.rainbowtext {
color: rainbow; /* (invalid) */
webkit-background-clip
and webkit-text-fill-color
makes browsers (including Chrome) apply the background to the text:-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
webkit-text-fill-color
and background-clip
(without vendor prefix) are supported by all major browsers except Internet Explorer in 2022), but we can still use a static font color as a fallback and make sure it doesn't look messed up. And we can set a smaller gradient size so that all colors are visible on the letters at once..rainbowtext {
color: red; /* fallback color */
background: linear-gradient(red, orange, yellow, green, blue, indigo, violet);
/* magic workarounds for modern browsers */
-webkit-text-fill-color: transparent;
background-clip: unset;
-webkit-background-clip: text;
/* make all colors visible at once */
background-size: 100% 60%;
}
.rainbowtext { /* ... */
animation: AnimateTextGradient 7s ease infinite;
}
@keyframes AnimateTextGradient {
0% { background-position: 50% 0; }
50% { background-position: 50% 100%; }
100% { background-position: 50% 0; }
}