Solved

opacity inside a div

Posted on 2008-10-29
4
399 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:wilq32
wilq32 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now