Jump to content

Recommended Posts

Posted (edited)

Hello,

 

I recently discovered the "opacity" property, which I find very exciting. One question here:

 

My html is very simple:

 






 

I want the container to be 50% opaque and the two other divs 100% opaque. I applied individual opacities for each div, like this:

 

#container {

filter: alpha(opacity=50) ;

opacity: .5 ;

background-color: #595959;

margin: 0px;

padding: 0px;

width: 960px;

height: 100%;

}

 

#leftcontent {

filter: alpha(opacity=100);

opacity: 1;

background-color: #CCCCCC;

height: 400px;

width: 500px;

margin-top: 20px;

margin-left: 20px;

margin-bottom: 20px;

float: left;

padding: 5px;

 

}

 

#rightcontent {

filter: alpha(opacity=100);

opacity: 1;

background-color: #CCCCCC;

height: 400px;

width: 500px;

margin-top: 20px;

margin-left: 20px;

margin-bottom: 20px;

float: right;

padding: 5px;

 

}

 

But it doesn't work. The two divs seem to inherit the 50% opacity property from the container. How do I assign independent opacities?

 

Thanks,

 

Eduardo

Edited by edoplaza
Posted

however daunting it might sound, when you experiment with opacity, try to write inline styles for your "opacity" divs first( for example):

This black text has 50% opacity applied

and then, if possible move them into external stylesheet:

 

 

Also, try this source , may be you'd get some ideas for your fix.

Posted

Elements inherit the opacity from parents and you can't go back to 100% (no opacity).

 

However, as Eric's link describes, if the elements not having the same degree of opacity are positioned over the top with position: absolute (ie not nested within the elements with opacity) they are isolated and therefore unaffected.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...