Add alpha/opacity to background image - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Image

Description

Add alpha/opacity to background image

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
div {<!-- w  ww .ja v a  2 s . co  m-->
   display:block;
   background:url('http://www.java2s.com/style/demo/Google-Chrome.png') 0 0 no-repeat;
   background-color:Chartreuse;
   background-size:cover;
   height:501px;
   width:501px
}

div:before {
   content:"";
   position:absolute;
   width:100%;
   height:100%;
   opacity:.5;
   z-index:2;
   background-color:yellow;
}
</style> 
 </head> 
 <body> 
  <div> 
   <h1>Hello, it's me!</h1> 
  </div>  
 </body>
</html>

Related Tutorials