Webkit 盒子阴影在其他元素之上出现问题

发布于 2024-12-28 02:13:44 字数 1094 浏览 3 评论 0原文

我有一些使用 transform:rotate()box-shadow 定位的导航元素。当您将它们悬停时,它们会稍微“弹出”,表明您可以单击它们。在 Chrome 和 Safari 中(表明这是一个 webkit 问题),当您将鼠标悬停在某些导航项上时,框阴影会变得混乱并覆盖其他随机元素的部分。它在 Firefox 中运行良好。

我做了一个 jsfiddle 来描述这个问题,就像我能弄清楚如何做一样:

http://jsfiddle.net/Q39eJ /1/

将鼠标悬停在前一个或前两个元素上,然后再移出,您将看到正在发生的问题。

我正在处理的网站存在问题:

http://temp.go-for-english。 com/

(URL 即将更改为 http://www.go-for-english.com 如果这个不起作用)

如果有人能找到解决方法仍然利用CSS3使其看起来正常(也许在悬停时再次设置z-index,或者我不确定的其他一些奇怪的解决方法)我非常感激它:)我真的不想诉诸于图片 :(

更新:

我被告知它在 Windows Chrome 上看起来很好 =\ 我使用的是 Mac OSX 10.6,这是我看到的行为的屏幕截图:

http://s9.photobucket.com/albums/a74/nZifnab/?action=view&current=Screenshot2012-01-19at13205PM.png

我的客户也指出了这个问题,因为他们使用 Safari。

I have some nav elements positioned with transform: rotate() and box-shadow. When you hover them they 'pop out' a little bit to indicate you can click on them. In Chrome and Safari (indicating this is a webkit issue) when you hover some of the nav items the box shadows go haywire and cover up portions of other random elements. It works fine in Firefox.

I made a jsfiddle portraying the issue as simply as I could figure out how to:

http://jsfiddle.net/Q39eJ/1/

Hover over and then out of the first one or 2 elements and you'll see the issue in action.

The site I'm working on has the issue here:

http://temp.go-for-english.com/

(URL will soon change to http://www.go-for-english.com if this one doesn't work)

If anyone can figure out a work-around that still utilizes CSS3 to make it look normal (Maybe set the z-index again on the hovers, or some other weird workaround that I'm not sure about) I'd greatly appreciate it :) I'd really rather not resort to images :(

UPDATE:

I've been informed it looks fine on Windows Chrome =\ I'm using Mac OSX 10.6, here's a screenshot of the behavior I see:

http://s9.photobucket.com/albums/a74/nZifnab/?action=view¤t=Screenshot2012-01-19at13205PM.png

My client has also pointed out the issue because they use Safari.

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

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

发布评论

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

评论(1

心的位置 2025-01-04 02:13:44

我想出了一些大部分有效的解决方法。发现这个 stackoverflow 问题:我该怎么办强制 WebKit 重绘/重绘以传播样式更改? 与使用 JavaScript 强制重绘元素相关。因此,我用此代码更新了我的小提琴,以强制重新绘制带有框阴影的元素:

$(function() {
    $('.top-nav a').hover(function() {
        redrawMe($('.top-nav a'));
    })
});

function redrawMe(obj) {
    obj.hide();
    obj.each(function() {
        this.offsetHeight;
    });
    obj.show();
}

我尝试仅重绘悬停的元素 redrawMe($(this)); 但它不起作用,当其中任何一个悬停时,我需要重新绘制所有它们。看起来大部分都成功了,但每个元素之间的裂缝中仍然出现一些较暗的阴影。我觉得这是可以接受的并且几乎不被注意到。 jsfiddle 与我的概念证明:

http://jsfiddle.net/nzifnab/Q39eJ/4/

尚未使用它更新该实时站点,但很快就会更新。

如果有人能设法找到一种方法,让每个元素之间的阴影消失,我会接受你的答案:)

同样,这可能只发生在 MacOS X 的 chrome 和 safari 上。

I figured out a bit of a work-around that mostly works. Found this stackoverflow question: How can I force WebKit to redraw/repaint to propagate style changes? related to forcing a repaint of elements using javascript. So I updated my fiddle with this code to force a repaint of the elements with box shadows:

$(function() {
    $('.top-nav a').hover(function() {
        redrawMe($('.top-nav a'));
    })
});

function redrawMe(obj) {
    obj.hide();
    obj.each(function() {
        this.offsetHeight;
    });
    obj.show();
}

I tried only redrawing the element that was being hovered redrawMe($(this)); but it didn't work, when any of them gets hovered, I need to redraw all of them. Appears to mostly do the trick but there's still some darker shadows that appear in the cracks between each element. I feel that this is acceptable and barely noticeable. jsfiddle with my proof of concept:

http://jsfiddle.net/nzifnab/Q39eJ/4/

Haven't updated that live site with it yet, but shall soon.

If anyone can manage to find a way to make even the shadows between each element disappear I'll accept your answer instead :)

Again, this may only be happening on MacOS X in both chrome, and safari.

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