Slide 5.30: CSS image opacity/transparency
Slide 5.32: CSS image opacity/transparency (cont.)
Home

CSS Image Opacity/Transparency (Cont.)


Example 2: Image Transparency—Mouseover Effect

Mouse over the images:      

The source code looks like this:

 <img src="klematis.jpg" style="opacity:0.4;filter:alpha(opacity=40)"
  onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100"
  onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40" />

 <img src="klematis2.jpg" style="opacity:0.4;filter:alpha(opacity=40)"
  onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100"
  onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40" />

We see that the first two lines of the source code is similar to the source code in Example 1. In addition, we have added an onmouseover attribute and an onmouseout attribute.
Demonstration
The following demonstration shows how the script of HTML and CSS is displayed on the Web: