IE6 PNG 替换:如何制作嵌套的 可点击?

发布于 2024-09-24 19:43:30 字数 1251 浏览 6 评论 0原文

出于此问题的目的,请考虑以下问题:

<div class="has_transparent_png">
    <a href="foo.html">
        <span>
            <img src="logo.jpg" />
        </span>
    </a>
</div>

问题:在 IE6 中, 不可点击。这是我正在使用的 PNG 替换:

.has_transparent_png {
    background-image: url(images/transparentpng.png);
}

* html .has_transparent_png {
    behavior: expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none", this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizingMethod='image')", this.src = "images/spacer.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("', '').replace('")', ''), this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "', sizingMethod='crop')", this.runtimeStyle.backgroundImage = "none")), this.pngSet=true));
}

How can I make the clickable?我无法控制 HTML。只有CSS。提前致谢。

For the purposes of this question, consider this:

<div class="has_transparent_png">
    <a href="foo.html">
        <span>
            <img src="logo.jpg" />
        </span>
    </a>
</div>

The Problem: In IE6, the <a> is not clickable. Here's the PNG replace I'm using:

.has_transparent_png {
    background-image: url(images/transparentpng.png);
}

* html .has_transparent_png {
    behavior: expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none", this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizingMethod='image')", this.src = "images/spacer.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("', '').replace('")', ''), this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "', sizingMethod='crop')", this.runtimeStyle.backgroundImage = "none")), this.pngSet=true));
}

How can I make the <a> clickable? I have no control over the HTML. Only the CSS. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

零度° 2024-10-01 19:43:30

不确定这是否有帮助,但似乎您正在设置 DOM 结构来修复 IE6 上的透明图像。您只需在特定 ID 上运行 js 函数即可使用如下脚本来修复图像的透明度: http://homepage.ntlworld.com/bobosola/pnghowto.htm

在页面底部执行类似的操作:

DD_belatedPNG.fix('#imgThatNeedsFix');

希望有帮助。

Not sure if this helps, but it seems that your are setting up that DOM structure to fix a transparent image on IE6. You may simply run a js function on specific ids to fix the transparency on images using a script like this one: http://homepage.ntlworld.com/bobosola/pnghowto.htm

Do something like this at the bottom of your page:

DD_belatedPNG.fix('#imgThatNeedsFix');

Hope that helps.

青衫负雪 2024-10-01 19:43:30

你可以尝试这样做..

.has_transparent_png a { position:relative; zoom:1; }

这并不总是有效...

另一种选择是使用兄弟div用png填充整个父div,然后有一个包含锚点并具有a的兄弟div更高的堆叠顺序。

You can try to do..

.has_transparent_png a { position:relative; zoom:1; }

This won't always work...

Another alternative would be to use a sibling div to fill up the entire parent div with the png and then have a sibling div to that which contains the anchor and has a higher stacking order.

愚人国度 2024-10-01 19:43:30

似乎没有办法严格通过 CSS 来做到这一点,而这正是预期的目标。

It seems as though there is no way to do this strictly through CSS, which was the intended goal.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文