Im playing around with CSS Opacity and I need to take a break from this nightmare! But before I do I figured I would post my problem here since maybe someone out there can help me.
Long story short is I want a background color with slight opacity, and the text / images to be full opacity. The solution which works the best for me is from trial and error is creating 2 DIVs, position them in the same spot on the screen. Div #1 will have a z-index of 0, and Div #2 a z-index of 1. DIV #1 will have the background and #2 the image/text.
The only problem with this is I want my layout to be center aligned AND I have specific pixel dimensions to follow. I have an easy enough time getting all of this centered but then I run into the problem of creating that semi-transparent background.
I have tried to do the following and havent succeeded either way. If anyone has any more suggestions please do tell!
Trial 1:
//Fake CSS Properties for example
Div#Holder{
opacity: 50;
}
Div#Image{
opacity: 100;
}
<Div ID="holder">
<Div ID="Image">
<Img src="ect.jpg" />
</Div>
</Div>
Well this doesnt work, since the image div is embedded in the holder div it inherits the holder div opacity properties for some reason!
Trial 2:
<Div ID="MainHolder">
<Div ID="holder">
</Div>
<Div ID="Image">
</Div>
</Div>
Using the same CSS above this creates 2 div elements, now this would work if I could make them overlap each other but when I try to make them position: absolute this creates the div to dissapear, I assume because it is nested within another div and becomes confused.
Now im no expert so please correct me if I did any stupid mistakes, just trying to learn something new. Hope someone can help out, thank you.



Reply With Quote

Bookmarks