CSS 背景颜色未按预期表现

发布于 2024-12-03 07:06:20 字数 1688 浏览 1 评论 0原文

我不明白为什么这里没有按预期应用背景颜色。这可能是我对CSS中元素之间的关系缺乏了解?

有问题的页面: http://www.preview.imageworkshop.com/portfolio/

< strong>复制问题

  1. 首先,在 IE 7IE 8 中打开上述链接
  2. ,单击“产品”过滤器,然后按“促销和促销”按钮。编辑过滤器
  3. 白点会出现在一些图像上(这是 IE 中的一个错误,导致一些像素在淡入淡出动画后保持透明。如果您没有看到它们,请多做一些过滤,它们会显示得相当好)

CSS 背景颜色问题

有效方法: 如果我将图库背景的背景颜色设置为红色,则该红色会通过图像上的透明点显示。 (这里的推论是,黑色背景颜色隐藏了“白点”错误)。

#isotopegallery{background:red;}

什么不起作用: 显然,我不想将图库背景颜色设置为白色以外的任何颜色。 我想要做的是设置包含图像的 DIV 的背景颜色,例如:

.photo{background:red;} 

但是,当我这样做时,红色背景颜色不会通过透明像素显示出来?

元素结构的简化概述如下

<div id="isotopegallery" class="photos">
    <div id="ngg-gallery-18-71">
        <div class="photo"> <p><a>  <img />  </a></p>   </div>
        <div class="photo"> <p><a>  <img />  </a></p>   </div>
        <div class="photo"> <p><a>  <img />  </a></p>   </div>
        <div class="photo"> <p><a>  <img />  </a></p>   </div>
    </div>
</div>

帮助!

我不明白为什么这个背景颜色适用于#isotopegallery父DIV,但不适用于.photo DIV?

当我查看 firebug 时,为 .photo div 设置了颜色属性,但没有通过透明像素显示?

这是他在我们网站上发布的最后一期,这让我发疯! 我非常感谢您为我解决此问题提供的任何帮助。

注意:有信息表明,在 Photoshop 中更改图像的黑点可以解决此问题。我们尝试过这个方法,发现行不通。

I don't understand why the background color is not being applied as expected here. This might be a lack of understanding on my part as to the relationships between elements in CSS?

The page in question: http://www.preview.imageworkshop.com/portfolio/

Replicating the issue

  1. First, open the above link in IE 7 or IE 8
  2. Click the PRODUCT filter, then press the PROMO & EDITORIAL filter
  3. White dots will have appeared on some of the images (this is a bug in IE which causes some pixels to be left transparent after a fade animation. if you don't see them, do a little more filtering, they turn up fairly quickly.

CSS BACKGROUND COLOR PROBLEM

What works:
If I set the background color for the gallery background to be red, then this red color shows throught the transparent spots on the images. (The inference here, is that a background color of black hides the 'white spots' bug).

#isotopegallery{background:red;}

What doesn't work:
Obviously, I don't want to set the gallery background color to be anything but white.
What I want to do is set the background color of the DIV that contains the images, for example:

.photo{background:red;} 

however, when i do this, the red background color does not show up through the transparent pixels??

The simplified overview of the structure of the elements is as follows

<div id="isotopegallery" class="photos">
    <div id="ngg-gallery-18-71">
        <div class="photo"> <p><a>  <img />  </a></p>   </div>
        <div class="photo"> <p><a>  <img />  </a></p>   </div>
        <div class="photo"> <p><a>  <img />  </a></p>   </div>
        <div class="photo"> <p><a>  <img />  </a></p>   </div>
    </div>
</div>

HELP!

I can't figure out why this background color works for the #isotopegallery parent DIV, but not for the .photo DIV?

When i look in firebug, the color property is set for the .photo div, but does not show through the transparent pixels?

This is the last issue that his holding up go live for our website, and it is driving me nuts!
I would really appreciate any help that you can provide to help me resolve this issue.

NOTE: there is info around that suggests that changing the blackpoint of the images in photoshop will fix this problem. We have tried this method, and have found it does not work.

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

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

发布评论

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

评论(3

尾戒 2024-12-10 07:06:20

您是否浮动 .photo 的内部元素而不清除它们?这将防止背景颜色覆盖相关元素的高度。

如果是这种情况,请附加类似
.photo div 应该可以解决问题。

同样,您始终可以尝试将背景颜色应用于 img 元素本身:.photo img { background-color: red;}

Are you floating the interior elements of .photo without clearing them? That would prevent the background color from covering the height of the element in question.

If that's the case, appending something like <br style='clear: both;' /> to the .photo div should do the trick.

Likewise, you could always try applying the background color to the img elements themselves: .photo img { background-color: red;}

天冷不及心凉 2024-12-10 07:06:20

isotope的创建者一直在帮我研究这个问题,并添加了以下评论:

“做了更多测试。我得出的结论是 IE 对待
包含图像的整个元素作为一个“图像”。不管是什么
可见变得扁平。如果该元素内有一个纯黑色像素
一个图像,该元素的像素将被视为
透明,无论图像后面实际是什么。

看看:http://support.metafizzy.co /2011/09-06-ie-trans.html

您会看到弹出几个透明像素,即使
每个项目的背景都是明显的红色(项目有填充,背景
是红色的)。然后我动态地将它们的颜色更改为蓝色,并将像素
仍然是透明的。

这意味着唯一的纯 CSS 解决方案是设置容器
背景为黑色”

不知道从这里到哪里去。我们尝试过移动黑点(因为这应该是由真正的黑色像素引起的),但发现这是一个不成功的方法。

The creator of isotope has been helping me look at this issue, and has added the following comment:

"Did some more testing. I've come to the conclusion IE treats the
entire element, which contains the image, as one 'image'. Whatever is
visible gets flattened. If that element has a true-black pixel within
an image, than that pixel of the element will be treated as
transparent, regardless of what's actually behind the image.

Take a look at: http://support.metafizzy.co/2011/09-06-ie-trans.html

You'll see a couple transparent pixels pop up, even though the
background of each item is clearly red (items have padding, background
is red). I then dynamically changed their color to blue and the pixel
is still transparent.

Which means the only pure-CSS solution is to set the container
background to black"

Not sure where to go from here. We have tried moving the black point (as this is supposed to be caused by true black pixels), but have found this to be an unsucessful method.

情深已缘浅 2024-12-10 07:06:20

我找到了这个问题的解决方案。我已经发布了针对此主题的完整详细信息(下面的链接),其中更详细地描述了该问题。

IE 淡入淡出导致图像上出现白点

I found a solution to this issue. I have posted full details against this thread (link below), which describes the issue in more detail.

IE fade causing white spots on images

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