Opacity applying on all inner div's - HTML CSS CSS Property

HTML CSS examples for CSS Property:opacity

Description

Opacity applying on all inner div's

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">
.outer {<!--  w w w . j  a  va  2  s. c o  m-->
   position:relative;
}

.outer:before {
   position:absolute;
   display:block;
   content:"";
   top:0;
   left:0;
   width:100%;
   height:100%;
   opacity:0.4;
   background-color:Chartreuse;
   z-index:-2;
}

.inner {
   opacity:2;
   background-color:yellow;
}
</style> 
 </head> 
 <body> 
  <div class="outer">
    Lore 
   <div class="inner">
     Lorem ipsu 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials