透明 PNG/GIF 雕刻出背后的背景图像

发布于 2024-10-14 09:46:48 字数 586 浏览 3 评论 0原文

我正在设计一个网站,但在我测试过的所有浏览器中都遇到了透明度问题。

以下是我希望图像的堆叠方式(从最低 z-index 到最高):

  1. 背景图块 (JPG)

  2. 倾斜相框 (PNG) // 显然,因为这是倾斜的,所以侧面需要透明,才能让背景图块 JPG 通过

  3. 倾斜照片 (PNG) 显示 // 它位于相框内,其边缘是也是透明的,这应该让相框在照片周围显示(视觉上)

出于某种原因,我的照片的透明部分雕刻出了相框的部分内容,因此我直接看到了背景图块,而不是透过相框显示(JPG) 。我宁愿将照片和相框分开,因为我打算实现一个脚本,该脚本可以在页面刷新时随机化相框中显示的照片。

我已将我所做的示例上传到 http://jezenthomas.co.uk/temp

在我的示例中,我使用了 GIF,但我在使用 PNG 时遇到了同样的问题。

当问题解决后,我会将其从我的网络空间中删除,所以我希望我已经为可能遇到同样问题的其他人提供了足够彻底的解释。

I am designing a site and I'm having transparency issues in all browsers I've tested in.

Here's how I want my images to stack up, from lowest z-index to highest:

  1. background tile (JPG)

  2. tilted photo frame (PNG) // obviously because this is tilted, it'll need to be transparent on the sides to let the background tile JPG show through

  3. tilted photo (PNG) // this sits inside the photo frame, and the edges of this are also transparent, which is supposed to let the photo frame display (visually) around the photo

For some reason, the transparent parts of my photo are carving out parts of the photo frame, so instead of the frame showing through, I'm seeing straight through to the background tile (JPG). I'd rather keep the photo and the photo frame separated because I intend to implement a script that randomises the photo that is displayed in the frame upon page refresh.

I have uploaded an example of what I'm doing to http://jezenthomas.co.uk/temp

In my example, I have used GIFs, though I experience the same problem with PNGs.

When the problem is fixed, I'll remove it from my webspace, so I hope I've explained it thoroughly enough for anyone else who might experience the same thing.

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

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

发布评论

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

评论(2

物价感观 2024-10-21 09:46:48

您的 元素与平铺背景图像具有相同的背景:)

您的 CSS:

html, body, div, [[[span]]]], applet, object, iframe, h1, h2, h3, h4, h5, h6, p, 
blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, font,
img, ins, kbd, q, s, samp, small, strike, sub, sup, tt, var, dl, dt, dd, ol, 
ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, 
tr, th, td {
    background-image: url("i/bg.jpg"); <----------
    border: 0 none;
    font-family: arial,serif;
    font-size: 100%;
    font-style: inherit;
    font-weight: inherit;
    margin: 0;
    outline: 0 none;
    padding: 0;
    vertical-align: baseline;
}

Your <span> element has the same background as your tiled background image :)

Your CSS:

html, body, div, [[[span]]]], applet, object, iframe, h1, h2, h3, h4, h5, h6, p, 
blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, font,
img, ins, kbd, q, s, samp, small, strike, sub, sup, tt, var, dl, dt, dd, ol, 
ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, 
tr, th, td {
    background-image: url("i/bg.jpg"); <----------
    border: 0 none;
    font-family: arial,serif;
    font-size: 100%;
    font-style: inherit;
    font-weight: inherit;
    margin: 0;
    outline: 0 none;
    padding: 0;
    vertical-align: baseline;
}
与风相奔跑 2024-10-21 09:46:48

您的重置 CSS 选择器将所有元素上的背景图像设置为 i/bg.jpg

Your reset CSS selector sets the background image to i/bg.jpg on all elements.

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