Skip navigation.

Forestgan

CSS layout in China

Posts tagged with "clip"

利用CSS 的 Clip 属性来创造 多彩文字(Multi Colored Text)

, , , ...

原理

将二个相同而色彩不同的文字重合在一起,通过分别给其加 clip 属性,使上面和下面的文字被剪切位置不同,从而产生二种不同的色彩。

clip : 摘自苏沈小雨CSS手册

clip : auto | rect ( number number number number ) 
 
参数: 
 
auto :  对象无剪切
rect ( number number number number ) : 
依据上-右-下-左的顺序提供自对象左上角为(0,0)坐标计算的四个偏移数值,其中任一数值都可用auto替换,即此边不剪切 
 
说明: 
 
检索或设置对象的可视区域。区域外的部分是透明的。
必须将position的值设为absolute,此属性方可使用。


测试环境

Firefox1.5、IE6.0、Opera8.5、IE5.01绿色版通过。

CSS

.textBottom {
color: #333333;
position: absolute;
left: 3em;
top: 1em;
font: 26px Century Gothic,Arial, Helvetica, sans-serif;
clip: rect(18px auto auto auto);
}

.textTop {
color: #CC0000;
position: absolute;
left: 3em;
top: 1em;
font: 26px Century Gothic,Arial, Helvetica, sans-serif;
clip: rect(0 auto 18px 0);
}

.container {
width: 28em;
height: 5em;
margin: 1em auto;
position: relative;
background: #F6F6F6;
}


xhtml

<div class="container">
 <a href="#" class="textTop">Cascading Style Sheet </a>
 <a href="#" class="textBottom">Cascading Style Sheet </a>
</div>


参考资料:

http://www.ibloomstudios.com/article8/

最终效果
December 2009
S M T W T F S
November 2009January 2010
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31