用CSS的Clip屬性創造多彩文字

來源:互聯網
上載者:User

原理

將二個相同而色彩不同的文字重合在一起,通過分別給其加 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>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.