Slide 5.31: CSS image opacity/transparency (cont.)
Slide 6.1: Programming Exericse III: A simple online bookstore for store owners only
Home

CSS Image Opacity/Transparency (Cont.)


Example 3: Text in Transparent Box

This is some text that is placed in the transparent box. This is some text that is placed in the transparent box. This is some text that is placed in the transparent box. This is some text that is placed in the transparent box. This is some text that is placed in the transparent box.


The source code is listed below:
 <html>
   <head>
     <style type="text/css">
       div.background {
         width: 500px;
         height: 250px;
         background: url(klematis.jpg) repeat;
         border: 2px solid black;
       }
       div.transbox {
         width: 400px;
         height: 180px;
         margin: 30px 50px;
         background-color: #ffffff;
         border: 1px solid black;
         filter:alpha(opacity=60);     /* for IE */
         opacity:0.6;                  /* CSS3 standard */
         -moz-opacity:0.6;             /* for Mozilla */
       }
       div.transbox p {
         margin: 30px 40px;
         font-weight: bold;
         color: #000000;
       }
     </style>
   </head>
   <body>
    <div class="background">
     <div class="transbox">
      <p>This is some text that is placed in the transparent box.
       This is some text that is placed in the transparent box.
       This is some text that is placed in the transparent box.
       This is some text that is placed in the transparent box.
       This is some text that is placed in the transparent box.
      </p>
     </div>
    </div>
   </body>
 </html>


Demonstration
The following demonstration shows how the script of HTML and CSS is displayed on the Web: