Setting the opacity of an element within a div with opacity defined by CSS - HTML CSS CSS Property

HTML CSS examples for CSS Property:opacity

Description

Setting the opacity of an element within a div with opacity defined by CSS

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">
#container {<!--from   w ww  .jav  a  2  s  .  c  o  m-->
   background:url('https://www.java2s.com/style/demo/Google-Chrome.png') no-repeat 0 -46px;
   overflow:hidden;
   font-family:arial;
   height:401px;
}

#menu {
   float:left;
   display:inline;
   margin-left:13px;
   border:3px solid Chartreuse;
   border-top:0;
   border-radius:0 0 11px 11px;
   behaviour:url('https://www.java2s.com/style/demo/Google-Chrome.png');
   position:relative;
}

#menu .bg {
   position:absolute;
   width:100%;
   height:100%;
   background:yellow;
   opacity:0.6;
   filter:alpha(opacity=51);
   left:0;
   top:0;
}

#menu li {
   float:left;
}

#menu a {
   text-decoration:none;
   position:relative;
   padding:9px 14px;
   color:blue;
   font-weight:bold;
   z-index:3;
   float:left;
}

#menu a:hover {
   color:pink;
}
</style> 
 </head> 
 <body> 
  <div id="container"> 
   <div id="menu"> 
    <span class="bg"></span> 
    <ul> 
     <li> <a href="#1">Lorem ips</a> </li> 
     <li> <a href="#1">Lorem ips</a> </li> 
     <li> <a href="#1">Lorem ips</a> </li> 
     <li> <a href="#1">Lorem ips</a> </li> 
    </ul> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials