png文件在IE中的透明度
我在 css 中将其设置为背景图像比内容部分稍大,以便在其后面有一个在 y 方向重复的阴影,但在 IE 中它不显示透明度。我曾使用谷歌尝试解决这个问题,但没有成功地用CSS完成图像。
CSS:
#shadow{
width:854;
margin-left:auto;
margin-right:auto;
text-align:left;
background-image:url(shadow.png);
background-repeat:repeat-y;
}
HTML:
<div id="shadow">
</div>
非常感谢任何帮助,因为我对此完全不知所措。
I have it set up in css to have the background an image slightly bigger than the content section so as to have a shadow behind it that repeats in the y direction but in IE it doesn't show the transparency. I have used google to try to solve this problem with no luck having done the image in css.
CSS:
#shadow{
width:854;
margin-left:auto;
margin-right:auto;
text-align:left;
background-image:url(shadow.png);
background-repeat:repeat-y;
}
HTML:
<div id="shadow">
</div>
Any help is greatly appreciated as I at a total loss on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果可能的话,你把 png 做成 gif,大家都很高兴。
如果这是不可能的,我使用的方法是仅 IE 的 css
行为
。通过
行为
,您可以链接到 htc 文件,如此处找到的文件:http://www.twinhelix.com/css/iepngfix/然后,您必须添加 CSS,例如:
behavior: url(iepngfix.htc)
If it's possible, you make the png a gif, and everyone is happy.
If that isn't possible, the approach I use is the IE only css
behavior
.With a
behavior
you can link to an htc file, like the one found here: http://www.twinhelix.com/css/iepngfix/You would then have to add CSS like:
behavior: url(iepngfix.htc)
IE7支持png透明。
如果您想支持 IE6,您可以使用浏览器门之类的东西(这是一个丑陋的黑客)。
在 CSS 中使用 IE<7 不支持的选择器:
IE6 会忽略 html>body #transparent_png 样式。然后,我们在单独的 .css 文件中使用丑陋的 DXImageTransform-filter 来在 IE6 中透明地显示 png。
但只有当 ie 版本低于 7 时才应加载此 css:
html header:
iefixes.css 包含类似以下内容:
不幸的是,此过滤器不支持重复 x 或重复 y。但通过这个gate hack,您可以为 IE 6 显示丑陋的抖动 gif 阴影,而不是更好的 png 阴影:)。
但是,DXImageTransform-filter 也有一个 sizingMethod 属性(请参阅 http://msdn.microsoft.com/en-us/library/ms532920%28VS.85%29.aspx),因此您可以将图像缩放到其容器元素的大小:
IE7 supports png transparency.
You could use something like a browser gate (which is an ugly hack) if you'd like to support IE6.
Use selectors in your CSS which IE<7 doesn't support:
the html>body #transparent_png style is ignored by IE6. Then, we use the ugly DXImageTransform-filter in a seperate .css file to display the png in IE6 transparently.
But this css should only be loaded if the ie version is less than 7:
html header:
The iefixes.css contains something like this :
Unfortunately, this filter does not support repeat-x or repeat-y. But with this gate hack, you could display an ugly dithered gif shadow for IE 6 instead of the nicer png shadow :).
But, there is also a sizingMethod property for the DXImageTransform-filter (see http://msdn.microsoft.com/en-us/library/ms532920%28VS.85%29.aspx), so you could scale the image to the size of its container element:
可以在这里找到针对 IE6 的非常好的 png 修复,
我使用了它并且可以向你保证它可以工作。
虽然是JS,但最近大多数人都打开了它
A very nice png fix for IE6 can be found here
I used it and can assure u it works.
It is JS though, but most people have it turned on lately
以上所有方法都可能有效,尤其是 alpha 图像加载器,它很好,但如果您打算使用它并希望将来依赖它,那么您最好使用另一种技术。
我发现的最好的是:DD_belatedPNG.js
它像树一样工作并且非常易于使用。
我与其他人遇到的问题是,当您想使用出现在背景顶部的链接时,会出现错误。如果没有进一步的破解,它们就无法工作。
All the above may work, especially the alpha image loader which is good, vut if you plan on using it and want to rely on it in the future then you are better using another technique.
The best I have found is:DD_belatedPNG.js
it works likke a treeat and is very easy to use.
The problem I have with the others is that there are bugs when you want to use links appearing over the top of the bg. They dont work, without further hacks.