?
Solved

opacity inside a div

Posted on 2008-10-29
4
Medium Priority
?
409 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 1000 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 1000 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
Suggested Courses

777 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