Solved

opacity inside a div

Posted on 2008-10-29
4
405 Views
Last Modified: 2012-08-13
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
Comment
Question by:vidhubala
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 250 total points
ID: 22829021
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
 
LVL 18

Assisted Solution

by:Pawel Witkowski
Pawel Witkowski earned 250 total points
ID: 22829396
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
 
LVL 82

Expert Comment

by:hielo
ID: 22831666
>>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
 

Author Closing Comment

by:vidhubala
ID: 31511070
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question