Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 414
  • Last Modified:

opacity inside a div

i have a transparent div and an image inside it. i dont want the image to be transparent. just the whole background needs to be transparent. image needs to look clear.pl help.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
 <head>
 <style>
 .tra {
	filter:alpha(opacity=22);
	-moz-opacity:.22;
	opacity:.22;
	}
</style>
 </head>
 <div class="tra" style="width:1000px">
 <table bgcolor="green"  width="1000">
	  <tr>
		  <td style="color:#ffffff;" width="1000">
			dadad
		  </td>
	  </tr>
	  <tr>
		  <td nowrap style="border:0" width="1000" align="center">
			<div style="width:500px"><img src="c.jpg" width="400" height="449" border="0" alt=""></div>
		  </td>
	  </tr>
	  <tr>
		  <td>
			gfg
		  </td>
	  </tr>
 </table>
 </div>
 </body>
</html>

Open in new window

c.jpg
0
vidhubala
Asked:
vidhubala
  • 2
2 Solutions
 
hieloCommented:
try:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
 <head>
 <style>
 .tra {
      filter:alpha(opacity=22);
      -moz-opacity:.22;
      opacity:.22;
      }
 #imgDiv {
      filter:alpha(opacity=99);
      -moz-opacity:.99;
      opacity:.99;
      }
</style>
 </head>
 <div class="tra" style="width:1000px">
 <table bgcolor="green"  width="1000">
        <tr>
              <td style="color:#ffffff;" width="1000">
                  dadad
              </td>
        </tr>
        <tr>
              <td nowrap style="border:0" width="1000" align="center">
                  <div style="width:500px"><img id="imgDiv" src="roundedge-blue-right.gif" width="400" height="449" border="0" alt=""></div>
              </td>
        </tr>
        <tr>
              <td>
                  gfg
              </td>
        </tr>
 </table>
 </div>
 </body>
</html>

Open in new window

0
 
Pawel WitkowskiSenior Javascript DeveloperCommented:
Hmm I was shocked that in this simple question hielo gave this bad answer o_O. Its not so simple as you would like to do. Just test it on firefox. In mine company we got similar problem. The easiest way to achieve this is to move image outside div that got opacity. Its because opacity on parent element affects childs and there is no know method (for me but as far as i know for noone too) to cancel opacity on elements inside this DIV. You can then position image relative to div, like this:

<div style="opaticy:0.22"></div>
<div style="position:relative;top:-40"><image></div>

0
 
hieloCommented:
>>Hmm I was shocked that in this simple question hielo gave this bad answer o_O...Just test it on firefox
I'm shocked you are shocked! :)  What I posted doesn't work on IE either. I pasted the wrong code, but yes, it doesn't work on FF. I was helping him on another problem that required IE functionality and didn't test on FF. This is what I had (without that extra css rule), but as you pointed out, would work only in IE (IE6 at least) :
<div style="position:relative;width:500px"><img...></div>

Open in new window

0
 
vidhubalaAuthor Commented:
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now