views:

116

answers:

1

I have a problem with IE8 where I cannot make <a> elements transparent. I've found these related SO questions but I haven't had any luck with the answers provided there:

I've tried "giving layout", by using zoom: 1;, but it hasn't helped. Here is my test CSS, lifted from the example on this page:

.test {
  background-color: #6374AB;
  width: 100%;
  color: #ffffff;
  zoom: 1;
}
.opaque1 {
  opacity: .5;
}
.opaque2 {
  filter: alpha(opacity=50);
}
.opaque3 {
  -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
}
.opaque4 {
  -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
  filter: alpha(opacity=50);
}

And the test HTML:

<p class="test">Test paragraph without opacity.</p>
<p class="test opaque1">Test paragraph with <code>opacity</code></p>
<p class="test opaque2">Test paragraph with <code>filter</code></p>
<p class="test opaque3">Test paragraph with <code>-ms-filter</code></p>
<p class="test opaque4">Test paragraph with compatibility note</p>

<p>
  <a class="test" href="#">Test anchor without opacity.</a><br/>
  <a class="test opaque1" href="#">Test anchor with <code>opacity</code></a><br/>
  <a class="test opaque2" href="#">Test anchor with <code>filter</code></a><br/>
  <a class="test opaque3" href="#">Test anchor with <code>-ms-filter</code></a><br/>
  <a class="test opaque4" href="#">Test anchor with compatibility note</a><br/>
</p>

In IE8, the opaque2, opaque3, and opaque4 paragraphs are transparent, but none of the anchors are. In IE6, the opaque2 and opaque4 paragraph and anchor both have transpareny.

+1  A: 

Try giving the anchor "display:block", but then you will have to fix its css properties like the width, height .... etc. But once you give the anchor the property "display:block" the opacity will work fine.

Naruto
thanks... but is there no way at all to make an inline object transparent in ie8? block has some problems because it doesn't work like text. (and it's not supposed to, of course.)
Jenni
What kind of problems occur when you use block ?? Is it stuff that you can solve using CSS ??
Naruto
if the link is in a block of text, the browser will want to put the link on its own line. i can float it, but if the link starts at the end of a line the block is still going to move down (blocks aren't split across lines of text like inline elements)
Jenni
Did you try inline-block ??? I always work that way and it works perfectly fine with me ...
Naruto
You were right. The `zoom:1` trick I used in IE6/7 has the same effect as `display:inline-block`. I never noticed the text wrapping problem before because I was using opacity in a tag cloud, where each link was very short text. you can see the text wrapping issue here: http://img689.imageshack.us/img689/3369/ieopacity.png (see how the semi-transparent text starts on a new line in the last screenshot?)
Jenni
I'm glad you're problem was solved :)
Naruto