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
Solved

opacity inside a div

Posted on 2008-10-29
4
403 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
  • 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

Suggested Solutions

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

791 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