- This topic is empty.
-
AuthorPosts
-
August 23, 2010 at 11:19 am #30012
telters
MemberHI there
So, I am creating a website, and I want the bg of the div to have an opacity of 0.6 (as you can see here), but it than makes my text that ‘translucent’ as well. Here is the HTML code:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Here is the CSS
#content1 {
opacity:0.6;
width:425px;
overflow:auto;
float:left;
padding-left:50px;
}
#content1 p {
padding-top:0px;
padding-bottom:50px;
background:#999;
color:#000;
opacity:1.0;
font-family:Tahoma, Geneva, sans-serif;
}How can I make the text have opacity of 1, and the background of the div an opacity of 0.6 without the text becoming that opacity?
August 23, 2010 at 11:34 am #81687TheDoc
MemberIt can’t be a part of the same div. You’ll need to create a background div (content-bg), and then create a content div (content) on top of it with no background.
August 23, 2010 at 11:40 am #81681telters
MemberThat would be my problem
So, now my code looks like this:
Hi there
With CSS like this:
#content-bg {
opacity:0.6;
width:425px;
overflow:auto;
float:left;
padding-left:50px;
background:#999;
}
#content1 {
padding-top:0px;
padding-bottom:50px;
color:#000;
opacity:1.0;
font-family:Tahoma, Geneva, sans-serif;
}Am I correct?
August 23, 2010 at 11:47 am #81671TheDoc
MemberTechnically, #content1 is still “inside” #content-bg.
I should have specified a little more – you’ll have to keep the #content-bg outside of the content. As in, content-bg can’t be wrapping anything.
Something like…
...
...
And then do some positioning trickery.
If the content-bg opacity is just a solid color, then you can do something much better! You can create a 1x1px square of #999 with .6 opacity, save it as a png-24 and use that as your repeating background. No need to worry about cascading styles!
August 23, 2010 at 11:55 am #81669telters
MemberAwesome! There’s my problem!
I kept trying to wrap content-bg around everything else, which wasn’t working
Thanks!
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.