opacity

Discussion in 'CSS' started by elombashy, Jan 20, 2012.

  1. #1
    hii
    I build a page with a div that has a background and a text in it.
    I want to give the background a- 0.4 opacity, but without affecting the opacity of the text.
    for some reason, the whole div with the text and the background gets 0.4 opacity.
    how to I assign a- 1.0 opacity for the text?
     
    elombashy, Jan 20, 2012 IP
  2. elombashy

    elombashy Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hiii
    I found this answer in the web:

    http://robertnyman.com/2010/01/11/css-background-transparency-without-affecting-child-elements-through-rgba-and-filters/

    thanx anyway
     
    elombashy, Jan 20, 2012 IP
  3. rlvassallo

    rlvassallo Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Provided youre using a selector for your element you can just assign the background of the designated element by using the following:

    
    <div id="rows">
         <div class="row1"><p>Designated as "row1"</p></div>
         <div class="row2"><p>Designated as "row2"</p></div>
    </div>
    
    HTML:
    
    #rows .row1,
    #rows .row2 {
         background-color: rgba(255,255,255,0.4);
    }
    
    /* this will assign just the background color of ".row1", and ".row2" to be set to white, with 40% opacity, not effecting the opacity of the text at all. */
    
    Code (markup):
    Resources: Hex to Rgba/Rgb converter: hex2rgba.devoth.com
     
    rlvassallo, Jan 20, 2012 IP
  4. yho_o

    yho_o Well-Known Member

    Messages:
    354
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    #4
    .selector{
    opacity:0.5; // this means %50 opacity always use number between 0.0 and 1.00 to adjust an element's opacity
    }
     
    yho_o, Jan 20, 2012 IP