Click here to Skip to main content
15,904,655 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all
i have two element DIV named by div1 , div2 that div1 contains div2.
i want div1 have opacity 0.5 but div2 have opacity 1 how?
i tried by following code but no luck!

CSS
div#div1
{
opacity : 0.5
}

div#div2
{
opacity : 1
}

html code:

HTML
<div id="div1">
<div id="div2">
...
</div>
</div>


thanks very much
abforce
Posted
Comments
Manoj S Rekya 9-May-13 4:09am    
You might have to use inline styling for div2. Inline styling overrides css.
Ali Reza Barkhordari 9-May-13 4:22am    
Please explain more , what's your mean about inline styling...

By design you can't. But there are methods to circumvent it. Look here: http://www.impressivewebs.com/css-opacity-that-doesnt-affect-child-elements/[^]
 
Share this answer
 
Try using !important for #div2

CSS
div#div1
{
opacity : 0.5
}

div#div2
{
opacity : 1 !important
}
 
Share this answer
 
Comments
Ali Reza Barkhordari 9-May-13 19:02pm    
This does not work on my browser (Firefox 20)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900