以下先給一個可直接貼進網頁檔案試跑的濾鏡綜合範例,再逐一拆解各效果。
<style type="text/css">
#panel div {
background-color: yellow;
height: 200px;
width: 200px;
}
</style>
<div id="panel" style="width:230px; height:230px; background-color:blue;">
<div style="filter:alpha(opacity=0, finishopacity=80, style=1,
startx=10, starty=10, FinishX=100, FinishY=100); opacity:0.5;">
</div>
可指定起始與結束透明度、方向與起始/結束座標,做出由透明到不透明的漸層遮罩。
<div style="filter:blur(add=1, direction=100, strength=5);"> <br/> add 為 1 代表文字有陰影,0 代表文字全部模糊。 abcdefghijklmnopqrstuvwxyz </div>
<div style="filter:chroma(color='#ff0000')"
onclick="this.style.backgroundColor='#ff0000'"
ondblclick="this.style.backgroundColor='black'">
<br/>
原為黃色,單擊變成紅色並轉為透明,雙擊變成黑色。
</div>
<div style="filter:FlipH;"> <br/> ABCDEFGH<br/> IJKLMNOP<br/> 此屬性在設定寬高後才有效。 </div>
<div style="filter:FlipV;"> <br/> ABCDEFGH<br/> IJKLMNOP<br/> 此屬性在設定寬高後才有效。 </div>
<div style="filter:gray;"></div>
需要提醒的是,這些 filter 都是 IE 的私有語法。現代專案若要達到模糊、翻轉、去色等效果,請改用 CSS3 的 filter 與 transform 標準屬性。