help with safari and opacity - Post...

User 423780 Photo


Registered User
8 posts

I have images that are at 1/2 opacity that go to 100% at mouseover and back to 50% at mouseout.
It works in IE + mozilla but not safari. How do I fix this? Here is the code:

<div class="grid_4 "><a href="westford.html"><img src="images/thumbnails/tn_bostonrd4.JPG" alt="" width="200" height="134" style="-moz-opacity:0.5;filter:alpha(opacity=50)" onmouseover="this.style.MozOpacity=1; this.filters.alpha.opacity=100" onmouseout="this.style.MozOpacity=0.5; this.filters.alpha.opacity=50" ></a></div>

Thanks
User 364143 Photo


Guest
5,410 posts

Try
-khtml-opacity: 0.5;
CoffeeCup... Yeah, they are the best!
User 25535 Photo


Registered User
11 posts

Without seeing it in action I know I wouldn't be able to help. I find it interesting that a Mozilla code works in IE at all. Have you thought of creating a dual image in CSS that changes the image when you mouse over it?

A sample code would be something like this:

<div class="rollover">
<p>
<a href="#"><img src="picture.gif"
width="32" height="32" border="0"></a>
</p>
</div>


<style type="text/css">
<!--
.rollover a { display:block; width:32px; background-color: #FFFFFF}
.rollover a:hover { background-color: #990000}
-->
</style>


This above codes use color, but you would change background-color to background-image.

You can even alter the code so that two images sit on top of one another as one, instead of the browser downloading two images and getting a minor flicker the first time around you can tell the styles to move up or down to display the next portion of a single image, thus getting no flicker.

...a very good example would be....

http://www.elated.com/articles/css-rollover-buttons/

I actually use the code at this link ALL the time for various sized images.

Katrina
User 423780 Photo


Registered User
8 posts

Got it to work using this code:
style="opacity:0.4;filter:alpha(opacity=40)"
onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100"
onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40" />

Seems the same to me as the first code but I'll need to take a closer look.

Thanks
User 463058 Photo


Ambassador
1,086 posts
Online Now

Interesting. I don't know much javascript so I just use this code:

a img.roll {opacity:0.4;filter:alpha(opacity=40)}
a:hover img.roll {opacity:1;filter:alpha(opacity=100)}


In this case all such images have the "roll" class.

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.