Tuesday, August 21, 2012

Transparency for Background color without affecting the text

My common method to give transparency for background color was

<p>Lorem ipsum</p>

P{
background-color:#000; 
opacity:0.2; 
color:#fff; 
display:block
}

This is going to take opacity for the text inside the p tag also.

Here is another method to get transparency to the background color without affecting the text.

 P{
   color:#fff;
    display:block;
    background: rgba(0,0,0,0.60);
}

And you are done!!

No comments:

Post a Comment