Search code examples
cssimagetransparency

Make image transparent in CSS


So here is my code, it works fine, but I want the image to be 50% transparent.

 #esc1{ 
 position: absolute; 
 top:30px; 
 right: 0; 
 width: 30px; 
 height: 30px;
 }

So sorry, I posted the wrong code before..


Solution

  • set opacity to your class for which you want to give transparency.

    eg :

    #esc1 {
     position: absolute; 
     top:30px; 
     right: 0; 
     width: 30px; 
     height: 30px;
     opacity: 0.5;
     } 
    

    you can give opacity with background, too

    eg : background : rgba(red_value , green_value , blue_value, alpha_value);

    red_value, green_value , blue_value are the combined value for your div background-color. and alpha_value is the opacity value to your div.

    Set opacity according to your need.

    Note : its value should be between 0 to 1 including 0 and 1.

    Hope this helps.