.rainbowtext{ background-image: -webkit-gradient( linear, left top, right top, color-stop(0, #f22), color-stop(0.15, #f2f), color-stop(0.3, #22f), color-stop(0.45, #2ff), color-stop(0.6, #2f2),color-stop(0.75, #2f2), color-stop(0.9, #ff2), color-stop(1, #f22) );
background-image: gradient( linear, left top, right top, color-stop(0, #f22), color-stop(0.15, #f2f), color-stop(0.3, #22f), color-stop(0.45, #2ff), color-stop(0.6, #2f2),color-stop(0.75, #2f2), color-stop(0.9, #ff2), color-stop(1, #f22) );
color:transparent;
-webkit-background-clip: text;
background-clip: text;
font-weight: bold; }
<p class="rainbowtext">Hello! This should have rainbow coloring.</p>
我想让一段文本呈现彩虹色。这段代码在Safari/Chrome中能够正常工作,但在Firefox中文字是透明的。我尝试过进行调整,但没有成功。有人可以帮忙吗? :P?
-moz-gradient
了吗? - daniel0mullins-webkit-background-clip: text
是 Webkit 特有的功能,不是标准属性/值。根据规范,background-clip
的可接受值为border-box
、padding-box
和content-box
。 - Hashem Qolami