I\'ve seen various examples of how to fade out a line of text in CSS. However, these all involve a gradient overlay which matches the background colour. Usually this might
There is a sleek solution which uses mask-image
. Yes, it uses a linear-gradient()
, however, because it works with pure transparencies, no knowledge of the background color is necessary:
div {
white-space: nowrap;
-webkit-mask-image: linear-gradient(to right, rgba(0,0,0,1) 90%, rgba(0,0,0,0));
}
Works for me in Chrome and caniuse for mask-image looks not bad.