Results 1 to 5 of 5

Thread: Opacity / Transparency

  1. #1
    Join Date
    Dec 2005
    Posts
    133
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Default Opacity / Transparency

    <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;
    /* for IE */
    filter:alpha(opacity=60);
    /* CSS3 standard */
    opacity:0.6;
    }
    div.transbox p
    {
    margin:30px 40px;
    font-weight:bold;
    color:#fff;
    }
    </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>

    i want by text to be white. but now i cant see it. is there a way?
    it lays on a semi transparent white bg

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You are putting white text on white. Then the div is faded-- but the text fades with it (I think).
    What do you want? 60% opaque white background with 100% opaque text, both white?

    You will need to use a semi-transparent background (and not transparent div), and the text will remain opaque.


    Alternatively you could try to position one div on top of another: semi-transparent div below as the background and text on the div above, fully opaque.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there emanuelle,

    Try it like this...
    Code:
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="language" content="english"> 
    <meta http-equiv="Content-Style-Type" content="text/css">
    
    <title></title>
    
    <style type="text/css">
    #background {
        position:relative;
        width:500px;
        height:250px;
        background:#c60 url(klematis.jpg) repeat; /*the #c60 is for testing and may be removed*/
        border:2px solid #000;
     }
    #transbox {
        position:absolute;
        width:400px;
        height:180px;
        margin:33px 48px;  /* these values give true centering */
        background-color:#fff;
        border:1px solid #000;
        /* for IE */
        filter:alpha(opacity=60);
        /* CSS3 standard */
        opacity:0.6;
     }
    #text {
        position:absolute;
        width:320px;
        height:120px;
        margin:65px 90px;  /* these values give true centering */
        font-size:13px;
        font-weight:bold;
        color:#fff;
     }
    </style>
    
    </head>
    <body>
    
    <div id="background">
    
    <div id="transbox"></div>
    
    <div id="text">
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
    Proin massa. Nam vehicula. Morbi velit nisi, mollis id, 
    ultrices luctus, adipiscing sit amet, lectus. Nunc rhoncus 
    nisl ac enim. Maecenas vestibulum dolor ut velit.Maecenas 
    condimentum pulvinar purus.Pellentesque ac ipsum.
    </div>
    
    </div>
    
    </body>
    </html>
    
    coothead

  4. #4
    Join Date
    Dec 2005
    Posts
    133
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Default

    fantastic

    thank you!

  5. #5
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    No problem, you're very welcome.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •