疊放兩層相同文字、不同顏色,分別套用 clip: rect(...) 剪裁不同區域,形成雙色/多色文字效果。

Firefox 1.5、IE 6.0、Opera 8.5、IE 5.01 綠色版通過。
.text-top {
position: absolute;
top: 0; left: 0;
color: #ff0000; /* 上半部顏色 */
clip: rect(0, 200px, 12px, 0); /* 裁切上半部 */
/* rect(top, right, bottom, left) */
}
.text-bottom {
position: absolute;
top: 0; left: 0;
color: #0000ff; /* 下半部顏色 */
clip: rect(12px, 200px, 24px, 0); /* 裁切下半部 */
}

<div class="text-container">
<span class="text-top">雙色文字效果</span>
<span class="text-bottom">雙色文字效果</span>
</div>

clip: rect(top, right, bottom, left);
position: absolute/fixed 元素生效。auto 表示不裁切該邊。clip 已棄用,現代請使用 clip-path:
.text-top {
clip-path: inset(0 0 50% 0); /* 保留上半部 */
}
.text-bottom {
clip-path: inset(50% 0 0 0); /* 保留下半部 */
}
或使用 background-clip: text + 漸層實現更豐富的文字填色:
.gradient-text {
background: linear-gradient(red, blue);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}