CSS Transparent effect

H

howachen

hi,

i have a table, and inside that table, there is an image.

i want to apply transparent effect on the table's background, but not
the image, what can i do with css?


sample html:

-----------------------------------------------------------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#mytable {
background-color: #FF0000;
opacity: .3;
filter: alpha(opacity=30);
-moz-opacity: .3;
}

-->
</style>
</head>

<body>
<table id="mytable" width="425" height="252" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td><img
src="http://www.google.com/logos/olympics06_hockey.gif"/></td>
</tr>
</table>
</body>
</html>
-----------------------------------------------------------------------------------

Thanks for any comment...


howa
 
J

Jim Higson

hi,

i have a table, and inside that table, there is an image.

i want to apply transparent effect on the table's background, but not
the image, what can i do with css?

Is the table's background an image? If so, try using a transparent PNG
perhaps.
 
H

howachen

The image is a jpeg or a gif.

If you have tried out my html above, you will see that both the table's
bg (i.e. red in color) & the image have been faded out. (using CSS)

My question is : how to apply this effect only on the table bg, but not
the image?

Thanks anyway...


Jim Higson 寫é“:
 
J

Jim Higson

The image is a jpeg or a gif. If you have tried out my html above,

'Fraid not. It'd be much easier to do so if you posted a link, copy+paste
into an empty document is tedious.
you will see that both the table's
bg (i.e. red in color) & the image have been faded out. (using CSS)

My question is : how to apply this effect only on the table bg, but not
the image?

Like I said, use a transparent PNG for the table background. If you only
want one colour in the table background, create a 1 pixel image of the
right colour/opacity and repeat it using the background-repeat rule.

This is what I do on this page:

http://surfcore.co.uk/forecasts

Notice how the breadcrumbs area is transparent, but not the crumbs
themselves. This is very similar to what you want.
 
N

Neredbojias

With neither quill nor qualm, Jim Higson quothed:
Like I said, use a transparent PNG for the table background. If you only
want one colour in the table background, create a 1 pixel image of the
right colour/opacity and repeat it using the background-repeat rule.

This is what I do on this page:

http://surfcore.co.uk/forecasts

That's one of the best pages I've ever seen. Nice...
 
J

Jim Higson

Neredbojias said:
With neither quill nor qualm, Jim Higson quothed:


That's one of the best pages I've ever seen. Nice...

Woot! So all that geeking on the computron wasn't entirely in vain. Now if
only you could tell potential advertisers the same...
 
H

howachen

well, the png solution doen't work very well with IE.

are there any pure css solution?

thanks.

Jim Higson 寫é“:
 
J

Jim Higson

well, the png solution doen't work very well with IE.

You can use AlphaImageLoader. With scaling the single pixel will fill the
table.

Bit of a hack, but probably the only way.
are there any pure css solution?

No. CSS can't specify RGBA colours.
 
J

Jim Moe

i have a table, and inside that table, there is an image.

i want to apply transparent effect on the table's background, but not
the image, what can i do with css?
After following the discussion, I am still not clear what you want to
do. Do you want the table's background-color to be transparent? If so,
that is easy: background-color:transparent.
Or do you want some part of the image to be transparent? Then use an
image editor to do that.
 
A

Andy Dingley

Woot! So all that geeking on the computron wasn't entirely in vain.

A well-deserved W00t! I think indeed. With all the usual rubbish that
gets posted here it's nice to see a page that looks so good and works so
well.

Couple of validation glitches that could be sorted with little effort,
but I imagine you'd tell me to go and chill my dudes out or something.
 
J

Jim Higson

Andy said:
A well-deserved W00t! I think indeed. With all the usual rubbish that
gets posted here it's nice to see a page that looks so good and works so
well.
Couple of validation glitches that could be sorted with little effort,
but I imagine you'd tell me to go and chill my dudes out or something.

Yeah, mostly on pages like http://surfcore.co.uk/forecast/croyde, becuase
<script>s can't be put directly inside a table body. Most of these script
tags are only there to fix in IE the <tr> they succeed.

There isn't a completely satisfactory place to put them. I can't put them
inside the <tr> they fix because then they could be called before it's been
properly added to the DOM, and if I put them in the next row... well...
that seems mixed up and out of place somehow.

I suppose the ones that are just for IE could be hidden with conditional
comments, but that seems like validation for its own sake.

The other non-validating HTML that I know of is on some node pages, like
this:

http://surfcore.co.uk/node/226

Here this is Drupal screwing up when it automatically breaks paragraphs from
the users' input. Short of forcing users to type <p> tags themselves I'm
not sure what can be done about this, but it's on the TODO list somewhere.

The single CSS sheet isn't valid, but only because of hacks to get things
working in IE. Since conforming browsers ignore rules they don't
understand, this shouldn't be a problem.

I wouldn't recomend trying to view the CSS in its 'live' form :)
 
D

dorayme

Jim Higson said:

Interesting design... You might want to know that in Safari some
things break when browser text-size is enlarged a few notches
from "normal" (what's normal?). Take, for instance, the blue
backgrounded box at right with "Weather Forecast...
Tried looking in your own backyard? The search engine for
Australians! Top 10 Stocks for 2006..." at
http://surfcore.co.uk/forecasts/blyth

Gets cut off at the bottom and text starts disappearing ("Ads by
Gooooogle" etc on bottom is first to go...)

In iCab, there is trouble on this score even at "normal" and
small text.

And in Firefox at more than small... I will stop here...
 
J

Jim Higson

dorayme said:
Interesting design... You might want to know that in Safari some
things break when browser text-size is enlarged a few notches
from "normal" (what's normal?). Take, for instance, the blue
backgrounded box at right with "Weather Forecast...
Tried looking in your own backyard? The search engine for
Australians! Top 10 Stocks for 2006..." at
http://surfcore.co.uk/forecasts/blyth

Gets cut off at the bottom and text starts disappearing ("Ads by
Gooooogle" etc on bottom is first to go...)

In iCab, there is trouble on this score even at "normal" and
small text.

And in Firefox at more than small... I will stop here...

That box is an Adsense ad. Nothing we can do about it, in fact it's a
violation of our contract with Google to try to fix their adverts' HTML.

Well, there is something we can do - get ads elsewhere. I'm writing our own
system at the moment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top