Forum Moderators: not2easy

Message Too Old, No Replies

Transparent backgrounds/Opaque Content

How to have opaque content inside transparent table/div

         

slimnutty5000

7:27 pm on Dec 11, 2007 (gmt 0)

10+ Year Member



I am having this problem with my table that has a transparent background and all the content (images, text) inside that table are transparent too. Here is the code im using:

style="background-color:#FFFFFF; opacity:.70;filter: alpha(opacity=70); -moz-opacity: 0.7;"

I found a tutorial that says to put a <div id="container"> around the content I want to be opaque, but that doesnt work in Firefox. This is the css used for the DIV:

#container {
filter:alpha(opacity=150);
-moz-opacity:1.5;
opacity: 1.5;
}

Can anyone point me to a site or give me some insights as to how to overcome this? I have seen a lot of websites that do have opaque content and transparent backgrounds (myspace, etc..) but cant get it to work.

Thanks for any help.

slimnutty5000

6:06 pm on Dec 12, 2007 (gmt 0)

10+ Year Member



Does this make any sense? Can anyone help?

penders

1:38 pm on Dec 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You could perhaps absolutely position an opaque element on top of your transparent container and avoid the transparency being inherited.

Or may be use a transparent PNG as your background-image and don't touch the transparency of the container at all?

Wayfarer

3:32 pm on Dec 13, 2007 (gmt 0)

10+ Year Member



The value of opacity must be betwen 0 and 1, 1 being 100% opacity (zero transparency) and 0 being invisible. Correct that and it will work in firefox. The -moz-opacity: selector is not needed and can be deleted.

Wayfarer

3:46 pm on Dec 13, 2007 (gmt 0)

10+ Year Member



here is how it should be:
<style>
#container {
filter:alpha(opacity=50);
/*-moz-opacity:1.5;*/
opacity: 0.5;
}
</style>

<body>

<div id="container">
<p>Now all contents of div are 50% transparent, including all text, backgrounds, and images</p>

<!-- Unfortunately, this div cannot have any children divs without all of them being transparent. You can set the transparency on #container's children to 0 (1.0 opacity), but it won't matter. This is the only curiosity to opacity rules, which are otherwise quite useful in application. -->

For example: take this test case:

<style>
body {
background: #03f;
}
div#transparent {
opacity: .5;
background: #060;
width: 200px;
padding: 10px;
position: absolute;
top: 35px;
z-index: 2;
}
div#not_transparent {
opacity: 1;
background: #fff;
}
</style>
</head>
<body>
<h2>Hello World</h2>
<div id="transparent">
<div id="not_transparent">
<h3>Hello World</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor.</p>
</div>
</div>

This is a test case I developed to illustrate this problem.
Paste it into Firefox with a Strict DOCTYPE. Note the opacity of the div#not_transparent.

slimnutty5000

9:34 pm on Dec 13, 2007 (gmt 0)

10+ Year Member



I tried your example and i get the same result as before. It works in IE but not in Firefox. Ive been researching google and still havent found a way around it.... someone knows it cause i see it all the time! lol. I think we are close, but I just need to get it to work in Firefox.

slimnutty5000

5:17 pm on Dec 14, 2007 (gmt 0)

10+ Year Member



Ok i gave up, and I used a Transparent PNG instead and it works just as good! I think ill use this method from now on until i figure out how to do it with CSS.

Thanks

penders

8:59 am on Dec 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Ok i gave up, and I used a Transparent PNG instead and it works just as good!

Is it OK in IE6?
[webmasterworld.com...]

slimnutty5000

4:49 pm on Dec 17, 2007 (gmt 0)

10+ Year Member



Yeah it works fine in all browsers. Its not an elaborate background, just a grey color. I would still love to find a way to do it using CSS or something, but for now , this works for me.