Background Opacity without breaking content to divs - HTML CSS CSS Property

HTML CSS examples for CSS Property:opacity

Description

Background Opacity without breaking content to divs

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">
section {<!--from  w  ww .  j  av a  2  s. c o m-->
   position:relative;
   text-align:center;
   padding:121px 0;
}

section:after {
   position:absolute;
   top:0;
   left:0;
   width:100%;
   height:100%;
   background-color:Chartreuse;
   content:'';
   transition:all .16s ease-in-out;
}

h2 {
   position:relative;
   z-index:2;
}

section:hover:after {
   opacity:.7;
}
</style> 
 </head> 
 <body> 
  <section> 
   <h2>Lorem i</h2> 
  </section>  
 </body>
</html>

Related Tutorials