Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
nested div's, transparency
Old 05-29-2008, 02:59 AM nested div's, transparency
Extreme Talker

Posts: 177
Trades: 0
I have a nested div, and the outermost div (the container) I have a solid white background, but what it to be partially transparent. to do this I have..

HTML Code:
-moz-opacity: 0.35; 
    filter: alpha(opacity=35);
in the css of the container. Unfortunately, it gives that attribute to everything...how can I prevent the transparency from being applied to the div's inside the container?
kbfirebreather is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-29-2008, 03:12 AM Re: nested div's, transparency
vn5ltr's Avatar
Skilled Talker

Posts: 93
Location: Melbourne, Australia
Trades: 0
I'd say the easiest thing to do would be to use a transparent png as the background of the parent div. Otherwise it'd mean playing around with relative positioning of elements i believe.
vn5ltr is offline
Reply With Quote
View Public Profile
 
Old 05-29-2008, 03:15 AM Re: nested div's, transparency
Extreme Talker

Posts: 177
Trades: 0
well I want it to be transparent on the site so you can kinda see the background.
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 05-29-2008, 03:27 AM Re: nested div's, transparency
vn5ltr's Avatar
Skilled Talker

Posts: 93
Location: Melbourne, Australia
Trades: 0
Which background are you talking about? The div itself or the actual background on the body/html?
vn5ltr is offline
Reply With Quote
View Public Profile
 
Old 05-29-2008, 03:36 AM Re: nested div's, transparency
Extreme Talker

Posts: 177
Trades: 0
the background of the div container
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 05-29-2008, 03:41 AM Re: nested div's, transparency
vn5ltr's Avatar
Skilled Talker

Posts: 93
Location: Melbourne, Australia
Trades: 0
Let me get this straight.

You have a div container that has nothing but a white background right? And you want that white background to be semi-transparent BUT all it's nested elements to be opaque. Correct?

If so, what i am saying is this:

Set the background of the main div container to have a tiled background of a semi-transparent png image that has a white colour.

That way, transparency is never set for elements via css, unless of course defining a alpha filter for IE < 6 to render those png images correctly.
vn5ltr is offline
Reply With Quote
View Public Profile
 
Old 05-29-2008, 03:59 AM Re: nested div's, transparency
Extreme Talker

Posts: 177
Trades: 0
Yes you are correct.

theres a container div (with the white background)

more div's are inside the container div, but the background of the container div should be the only thing transparent, and the rest opaque.

I'm not to sure on how to go about what you are saying though.
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 05-29-2008, 04:07 AM Re: nested div's, transparency
Extreme Talker

Posts: 177
Trades: 0
What if I have 2 div's placed on top of eachother...one with the transparent background, the other with the content?

I'm not to sure how to place them on top of another though...
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 05-29-2008, 04:08 AM Re: nested div's, transparency
vn5ltr's Avatar
Skilled Talker

Posts: 93
Location: Melbourne, Australia
Trades: 0
Create a new document in photoshop, sized say 50px by 50px.
Create a new layer, fill it with white and set transparency to around 70%.
Delete the background layer after (default layer).
Save it as a png, then use it as the background of your main div layer.

HTML Code:
div.mainDiv {
background:transparent url(image_path/png_bg_image.png) repeat;
}
That should do it. Replace paths, filenames and div class names as necessary.

For IE < 7, refer to this site:

http://homepage.ntlworld.com/bobosola/pnghowto.htm
vn5ltr is offline
Reply With Quote
View Public Profile
 
Old 05-29-2008, 04:43 AM Re: nested div's, transparency
Extreme Talker

Posts: 177
Trades: 0
You are....awesome! Worked like a charm!
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 05-29-2008, 10:48 AM Re: nested div's, transparency
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Be sure to check the results on IE6. This method won't work in that browser of course. You may need an alternative solution for 6. Hopefully you can live without transparency in one browser.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 05-29-2008, 11:00 AM Re: nested div's, transparency
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
Quote:
how can I prevent the transparency from being applied to the div's inside the container?
You can't, at least not that way. Opacity is INHERITED and you can't turn it off.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 07-29-2008, 12:19 PM Re: nested div's, transparency
Junior Talker

Posts: 1
Name: SMD
Trades: 0
New to the site and still just trolling around... maybe a dead topic here but...

You can use nested div's and create transparent colored layers with just CSS.

You have to use some relative or absolute placement of your div's. It's not incredibly flexible yet... and you have to sort of design around the limitations at this point.

I've used this tactic on many sites and had success across all browsers.

Transparent layer has a fixed location, height, and width.
You can then fix your content div to the same size or not depending on your needs and design.
Place the content div in the same X,Y location relative to the 'container' DIV, and give the content div a higher Z-Index then the transparent color div.
This effectively places the 2 layers in the same place 1 on top of the other, and eliminates the parent-child relation.

Code:
<div id="container">
   <div id="transparentcolor"></div>
   <div id="content"><p></p></div>
</div>
seems rather constricting at first, but once you get the hang of it, makes for some great looking stuff.
~SMD
daughertysm is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to nested div's, transparency
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.58498 seconds with 12 queries