School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,401 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,580 people online right now. Registration is fast and FREE... Join Now!




CSS Opacity

 

CSS Opacity, Div using opacity

denoteone

23 Jun, 2009 - 07:30 AM
Post #1

New D.I.C Head
*

Joined: 1 Apr, 2009
Posts: 4


My Contributions
I am noticing that if i have a container div that has a white background and I lower the opacity in the div using css that the black text is getting washed out as well. I tried to set the opacity of the <p> in the div to 100% but that does not work. Can anyone help me with this? or has any ideas?

Thanks, Denoteone.



User is offlineProfile CardPM
+Quote Post


BetaWar

RE: CSS Opacity

23 Jun, 2009 - 09:07 AM
Post #2

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 4,729



Thanked: 269 times
Dream Kudos: 1400
My Contributions
Opacity in CSS effects the element you set it for and all elements under it. So if you have somthing like so:

CODE

div.op
- span
- - div
- - - div


and set the opacity for div.op to 80% (.8 or 80 depending on browser) the max opacity for everything inside div.op is 80.

If you want just the background to be transparent I would suggest looking at making a semi-transparent .png file and setting that as the background for the object.

Hope that makes sense.
User is offlineProfile CardPM
+Quote Post

Beki

RE: CSS Opacity

26 Jun, 2009 - 11:27 AM
Post #3

New D.I.C Head
*

Joined: 16 Jun, 2009
Posts: 18


My Contributions
You could also absolutely position an identical div on top of it, with all your text in. This isn't very semantic though...I have some semi-transparent png I could link you to use if you want. ohmy.gif A 40% one and 60% one lol.
User is offlineProfile CardPM
+Quote Post

forest51690

RE: CSS Opacity

30 Jun, 2009 - 08:04 AM
Post #4

D.I.C Head
Group Icon

Joined: 20 Mar, 2009
Posts: 115



Thanked: 17 times
Dream Kudos: 50
My Contributions
don't you wish css had a background-opacity property?

transparent pngs are the way to go, but you have to jump through some hoops with MSIE.
User is offlineProfile CardPM
+Quote Post

BetaWar

RE: CSS Opacity

1 Jul, 2009 - 01:47 PM
Post #5

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 4,729



Thanked: 269 times
Dream Kudos: 1400
My Contributions
QUOTE
don't you wish css had a background-opacity property?

Yes, yes I do.

QUOTE
transparent pngs are the way to go, but you have to jump through some hoops with MSIE.

Only IE <7. IE 7 and 8 allow .png images to have transparency, and render it correctly too. My general stance here is don't worry about implementing the IE 4, 5 and 6 hack to get the transparency correct for .png images, just build like people are using IE 7+, FF, Chrome or Opera (I dislike Safari, so I leave it alone - totally).
User is offlineProfile CardPM
+Quote Post

hadi_php

RE: CSS Opacity

1 Jul, 2009 - 07:40 PM
Post #6

D.I.C Regular
***

Joined: 23 Aug, 2008
Posts: 259



Thanked: 5 times
My Contributions
on css you need to include this

CODE

filter:alpha(opacity=60);
opacity:0.6;


or

CODE
<img src="yourimage.jpg" style="opacity:0.4;filter:alpha(opacity=40)"
onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100"
onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40" />

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 10:18PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month