/    Sign up×
Community /Pin to ProfileBookmark

some more png/IE issues

So, I’m not 100% concerned because I have my code working in every other browser and as far as I’m concerned if you actually use IE you should die a slow painful death. But microsoft does have most of the market, so I should try and fix all the bugs I can.

I made a post recently about switching transparent pngs in IE using the :hover pseudoclass. Here is a snippet of what I ended up doing (pretty much the same as the recommendations made in that post)

In the CSS:

[CODE]
<!–[if lte IE 6]>
<style type=”text/css”>

.mainMenu img
{
visibility: hidden;
}

.mainMenu a
{
cursor: pointer;
}

#menu1
{
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=’images/menu/menu1.png’, sizingMethod=’scale’);
}

#menu1:hover
{
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=’images/menu/menu1Hover.png’, sizingMethod=’scale’);
}
</style>
[/CODE]

(Is there a reason the cursor wouldn’t automatically switch to pointer over the links???)

In the HTML:

[CODE]
<a id=”menu1″ title=”Check out the latest” href=”/?section=main”><img alt=”What’s New” src=”images/menu/menu1.png”><img class=”over” alt=”What’s New” src=”images/menu/menu1Hover.png”></a>
[/CODE]

The two images are there so that I can switch them in non IE browsers. The hover image doesn’t have a space created for it because it has [B]display: none;[/B] applied to it in another style.

Anyway, the switch does take place in IE but not very well. It only happens when the mouse is directly over the text and not the box that the A tag should create (the link has the same size of the image because I use the visibility attribute to hide the image rather than using the display).

I don’t know if this is clear, but if the mouse is directly over (for example) an “a” in the image then the switch happens, but if the mouse is over the space between letters, words or even over the hole in an “a” then the old image is displayed again. So, if you move the mouse while over the image, it flickers a lot.

Is there a way to fix it, or is this just beyond IE???

Thanks,
Douglas

PS [URL=http://www.webdeveloper.com/forum/showthread.php?t=111713]This is my previous post on switching pngs[/URL]

to post a comment
CSS

10 Comments(s)

Copy linkTweet thisAlerts:
@KDLAJul 03.2006 — (IE, before version 6, doesn't recognize "pointer." It used to use the style "pointing hand.")

Add display: block to your link styles.

KDLA
Copy linkTweet thisAlerts:
@DJRobThaManauthorJul 03.2006 — Actually, adding display: pointer works (at least on my machine) for IE. display: block would solve my rollover problem???

Thanks
Copy linkTweet thisAlerts:
@KDLAJul 03.2006 — Sorry - I thought you asked why the pointer didn't work.

Yes. You may have to add a width to your link <a> styles, so the block will be defined. But, until you add display: block, the browser will only recognize the text as the link, not the area around it.

Reference: http://www.w3.org/TR/CSS21/visuren.html#q5

KDLA
Copy linkTweet thisAlerts:
@DJRobThaManauthorJul 03.2006 — Thanks a lot!
Copy linkTweet thisAlerts:
@DJRobThaManauthorJul 03.2006 — So, I just tried display: block. And even when I gave the anchors widths and heights I'm still having the same problems... Is there anything else you think I could try to fix it?????


Thanks so much for your help,

Douglas
Copy linkTweet thisAlerts:
@KDLAJul 04.2006 — Not without seeing the page. Sometimes something else in the coding can cause problems. Can you send a link?

KDLA
Copy linkTweet thisAlerts:
@DJRobThaManauthorJul 04.2006 — I hadn't uploaded it yet actually, but I will when I get home so you can see it
Copy linkTweet thisAlerts:
@DJRobThaManauthorJul 04.2006 — It's up now at [URL=http://www.fourlinefilms.com/flf]this page[/URL].

Thanks for the help,

Douglas
Copy linkTweet thisAlerts:
@KDLAJul 05.2006 — You've chosen an unconventional way of coding your rollovers. Normally, you choose an image background, then on the a:hover have it change.

The way you've implemented those transparent .png with a display switch may be the reason. You've assigned the pointer (link action) to the image, which, if the background is transparent, would mean that it would only work when touching the text. Assigning the images as "display:inline-block" may work.


If not, I suggest using the image (text with background, not transparent) as a background for the link, make the link text invisible to the screen, and have the rollover based upon the a:hover.

KDLA
Copy linkTweet thisAlerts:
@DJRobThaManauthorJul 08.2006 — I just fixed my problem. If you look in the IE css file you'll see I applied [B]visibility: hidden;[/B] to all the images in the menu. I changed that and, instead, applied a filter so that opacity is set to '0' so you can't see it (pretty much the same thing).

I guess this is because (I'm still not convinced but this sounds half-right at least) with the opacity set to '0' the image is still there. But with [B]visibility: hidden;[/B] even though the space for the image is where it should be, the actual image isn't there. So the <a> tag is filled with empty space and the hover gets screwed up.

Does this explanation make sense? I really would like to understand why my fix works. Please, let me know what you think.

Douglas
×

Success!

Help @DJRobThaMan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...