473,416 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

How can I give an element a semi-transparent background?

Hi.

I have a transparent PNG-image that I would like to display on top of
the rest of the web page. I've already got this part working. But, I'd
like the background (as in "the part of the image that is transparent"),
to be semi transparent instead. So, I've wrapped the image in a
div-tag with the style "opacity: .70" instead. This gives me pretty
much the semi transparency that I'm looking for, except that this makes
the entire image transparent as well. I tried setting the opacity of the
image to 1.0, but that didn't make any difference.

As a workaround, I've taken the image out of the div-tag, and positioned
them on top of each other. This "works", but it really doesn't "feel"
right. It's a clumsy solution, and I was hoping there's a better way to
do this.

So, is it possible to set the opacity of an element without affecting
the opacity of the element's children?

--
Trond Michelsen
Aug 23 '06 #1
2 2694
Trond Michelsen wrote:
I have a transparent PNG-image that I would like to display on top of
the rest of the web page. I've already got this part working. But, I'd
like the background (as in "the part of the image that is transparent"),
to be semi transparent instead.
Why not alter the PNG to have a semi-transparent background, instead of
fully transparent? At the risk of answering my own question, IE 6 or
eariler would make such a PNG entirely opaque. But that may be the
case already, depending on which transparency style your PNG uses.
8-bit PNGs have essentially the same capabilities as GIFs, except
without animation. There is a 256 color limit, with "transparent"
counting as a color. IE 6 displays these correctly. There are also
32-bit PNGs, where each pixel can be any color at any opacity. IE 6
renders these incorrectly, and the result is essentially the intended
image plastered onto a solid gray rectangle. IE 7 promises to display
these images correctly.

I'd be glad to alter your PNG for you if you don't mind alienating IE 6
users.

--
Vid the Kid

Aug 26 '06 #2
VidTheKid wrote:
Trond Michelsen wrote:
>I have a transparent PNG-image that I would like to display on top of
the rest of the web page. I've already got this part working. But, I'd
like the background (as in "the part of the image that is transparent"),
to be semi transparent instead.
Why not alter the PNG to have a semi-transparent background, instead of
fully transparent?
Well, the PNG is generated on the fly from a program called mapserver,
and although it's possible to get mapserver to generate 32-bit PNGs,
there's no opacity setting, only transparency on/off.
At the risk of answering my own question, IE 6 or
eariler would make such a PNG entirely opaque. But that may be the
case already, depending on which transparency style your PNG uses.
Right. It's opaque in IE6 at the moment, but I don't worry too much
about that right now. I'll deal with IE later.
I'd be glad to alter your PNG for you if you don't mind alienating IE 6
users.
I'd gladly let you fix them, if it had been a finite number of PNGs :)

I guess I could do som trickery on the webserver to send the images
through ImageMagick, and fix the transparency here, but if there's a CSS
solution, I'd rather use that.

--
Trond Michelsen
Aug 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dennis M. Marks | last post by:
I am never sure of when a semi-colon is required in javascript. Is there a definite rule? -- Dennis M. Marks -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----...
4
by: George Hester | last post by:
I have a form that has 4 <INPUT> elements in it each with a unique id. The page loads with the <INPUT> id = 1 with focus. If a tab is done immediately without entering anything in this INPUT text...
1
by: J. Potts | last post by:
Just out of curiosity, has anyone run into this problem? Someone where I work put a set of pages together with the following in the style sheet: BODY { position: absolute; margin-top: 0mm;...
18
by: matt | last post by:
hello, i am experiencing a little problem w/ regards to IE & Firefox compatibility (works as expected in firefox, doesnt in IE). i have a container-div element, which contains 1 image, and 2...
5
by: mavis | last post by:
the reference of the content of XML element In XSD, how can I specify the content of an element refers to the content of another element in an xml file? Thanks a lot!
6
by: mandibdc | last post by:
I need to extract some elements from a very large XML file. Because of the size, I'd like to work with it on my Linux machine as a text file. Basically, I am going to have a list of specific...
6
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why doesn't the global variable "divId" always refer to the element with id="divId"?...
2
by: James Stroud | last post by:
Hello All, I am trying to create a semi-standalone with the vendor python on OS X 10.4 (python 2.3.5). I tried to include some packages with both --packages from the command and the 'packages'...
4
by: Steve | last post by:
I thought that this was available for all elements in Firefox, but recently had a page where a div didn't have it. I put in an id style for it, thinking that would do the trick, but it didn't. ...
13
by: Alex | last post by:
For example, i have some part of XML file. <AppSettings> <Object ClassVersion="1.0.0.0" Type="AppSettings"> <Fields> <Field Name="App_ID" Type="System.Int32"> <Value> <int>-1</int> </Value>...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.