如何制作内联png 使用CSS透明?

发布于 2024-09-02 13:50:59 字数 553 浏览 5 评论 0 原文

如何使div内的内联png透明? 使用 css

<div id="report'>
<p> some text </p>

<img src=transparent.png" />

</p>

</div>

例如, 这是图像。除了球之外,我想使其他白色区域透明。在 IE6 中看起来是灰色的

alt text

我想在 css 中这样做 div#report img {.....} 可能吗?

编辑:

我不想使整个图像透明

更新:

这里我添加了示例http:// /jsbin.com/ubabo3

How to make inline png transparent inside div? using css

<div id="report'>
<p> some text </p>

<img src=transparent.png" />

</p>

</div>

this is image for example . Other than ball i want to make transparent other white area. Which is looking grey in IE6

alt text

I want to do in css like this div#report img {.....} is it possible?

Edit:

I don't want to make whole image transparent

Update:

Here i added example http://jsbin.com/ubabo3

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

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

发布评论

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

评论(6

你好,陌生人 2024-09-09 13:50:59

IE 6 默认不支持透明 png 文件。您需要使用一个小技巧来实现透明的 png 文件。

http://support.microsoft.com /?scid=kb%3Ben-us%3B294714&x=12&y=11

IE 6 does not support transparent png files per default. You need to use a small hack to achieve transparent png files.

http://support.microsoft.com/?scid=kb%3Ben-us%3B294714&x=12&y=11

本宫微胖 2024-09-09 13:50:59

试试这个:

div#report img{
    background-color/**/: #000000;
    background-image/**/: none;
    opacity: 0.7;
    filter: alpha(opacity=70);
}

Try this:

div#report img{
    background-color/**/: #000000;
    background-image/**/: none;
    opacity: 0.7;
    filter: alpha(opacity=70);
}
浅唱々樱花落 2024-09-09 13:50:59

opacity 属性适用于所有元素(在支持的浏览器中)。

The opacity property applies to all elements (in supporting browsers).

你丑哭了我 2024-09-09 13:50:59

我不确定我是否理解,但是您可以使图像完全透明(即不可见):

div#report img { visibility: hidden } // Still takes up space
div#report img { display: none } // Hidden entirely - 

但是,不可能仅将其应用于 png 图像,至少在 CSS 2.1 中是不可能的。通过使用检查 src 属性中的 .png 的选择器,当然可以使用一些额外的 jQuery 魔法。

I'm not sure I understand, but you can make an image completely transparent (i.e. invisible):

div#report img { visibility: hidden } // Still takes up space
div#report img { display: none } // Hidden entirely - 

it is not possible, however, to apply this only to png images, at least not in CSS 2.1. It's surely possible using some additional jQuery magic by using a selector that checks for .png in the src property.

话少情深 2024-09-09 13:50:59

您无法使用 CSS 将对 PNG 半透明的支持添加到 IE6。有一些 hack(其中一些涉及 IIRC,将 ActiveX 内容调用到样式表中)和 Google 会为您找到很多东西

(然而,现在我注意到 IE6 距离生命周期结束只有几周的时间,在我的目标受众中占有很小的市场份额,并且拒绝做额外的工作来说服它看起来不错)

You can't add support for PNG translucency to IE6 using CSS. There are hacks (some of which involve, IIRC, calling ActiveX stuff into a stylesheet) and Google will find lots for you.

(These days, however, I'd note that IE6 is just a few weeks away from End of Life, has a small marketshare among my target audience, and refuse to do extra work to persuade it to look nice)

南街女流氓 2024-09-09 13:50:59

我之前必须处理 IE6 PNG 问题,这很有效。

你要做的就是向你的文件添加一个“行为”属性

div#report img { behavior: url(iepngfix.htc) } 

,你可以下载该文件 - iepngfix.htc 此处 并检查 在线演示 ..它一步一步解释了一切

I had to deal with IE6 PNG problems before and this worked ..

what you do is add a "behavior" attribute to your

div#report img { behavior: url(iepngfix.htc) } 

and you can download the file - iepngfix.htc here and check the online demonstration .. it explains everything step by step

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