Transparency Effects
You can create transparency effects in CSS by using the following syntax :- filter: alpha(Opacity=??, FinishOpacity=??, Style=?, StartX=??, StartY=??, FinishX=??, FinishY=??);
Opacity=??
Sets the opacity of the object. 0 = invisible, 100 = completely visible. Sets the start opacity when used in conjunction with FinishOpacity.
FinishOpacity=??
Sets the opacity for the end of the of the object. Creates a gradient effect.
StartX=??, StartY=??, FinishX=??, FinishY=??
Sets the coordinates for the opacity to start or end.
Style=??
Sets the type of gradient. 1 = Horizontal; 2 = Radial; 3 = Rectangular.
This trick will work only in IE 5.x and above browsers. |
Example:
1. | Style = 1 |
2. | Style = 2 |
3. | Style = 3 |
4. |
Code:
<p
style="FILTER: alpha(finishopacity=0, style=1);
>Style = 1</p>
WIDTH: 120px; COLOR: #ffffff" align=middle width=120 bgColor=#808080"<p
style="FILTER: alpha(finishopacity=0, style=2);
>Style = 2</p>
WIDTH: 120px; COLOR: #ffffff" align=middle width=120 bgColor=#808080"<p
style="FILTER: alpha(finishopacity=0, style=3);
>Style = 3</p>
WIDTH: 120px; COLOR: #ffffff" align=middle width=120 bgColor=#808080"<img
style="FILTER: alpha(finishopacity=0, style=2)" width="71" height="33"
src="csstutorial.gif" alt="image transperancy" border="0">
Using this technique and you can add a mouseover effect on an image. The browser is doing all of work so there is no extra download time. This is a great way to add rollover effects without weighing down your page. Here's how.
Example:
Move the mouse over the image to see the rollover effect.
Code:
<imgonmouseover="this.filters.alpha.opacity='100'" style="FILTER: alpha(opacity=50)"
onmouseout="this.filters.alpha.opacity='50'"
width="75" height="43" SRC="csstutorial.gif" alt="transperancy mouseover" border="0">