Webkit 中奇怪的边框不透明行为?

发布于 2024-10-09 04:42:25 字数 616 浏览 0 评论 0原文

我一直在测试不透明的边框,Webkit 似乎有一个奇怪的行为。

这是我的代码,

<style>
div{
    position: relative;
    width: 300px;
    height: 300px;
    background: #00f;
}
span{
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 10px solid rgba(255, 255, 255, 0.5);
}
</style>
<div>
    <span></span>
</div>

您可以在此处进行测试。在 Firefox 中,您将得到预期的结果:一个 10px 的白色内边框,div 周围的不透明度为 50%,但是,至少 Chrome(但我怀疑 Webkit)似乎与边框的边框重叠(不知何故这是有道理的)。我认为这不是故意的,因为它似乎是重叠的!

这是一个错误还是只是一个预期的功能?

I've been testing with borders with opacity and Webkit seems to be having a weird behavior.

Here's my code

<style>
div{
    position: relative;
    width: 300px;
    height: 300px;
    background: #00f;
}
span{
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 10px solid rgba(255, 255, 255, 0.5);
}
</style>
<div>
    <span></span>
</div>

You can test it here. In Firefox you'll get as expected: a 10px white inner border with 50% opacity around the div, however, at least Chrome (but I suspect Webkit) seems to be overlapping the border's borders (somehow that makes sense). And I think it's not intented, since it seems to be overlapping itself!

Is this a bug or just an intended feature?

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

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

发布评论

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

评论(2

葬花如无物 2024-10-16 04:42:25

Chrome 问题列表中的错误(猜猜看,没人关心):
http://code.google.com/p/chromium/issues/detail?id=36475&q=transparent%20border%20color&colspec=ID %20Stars%20Pri%20Area%20Feature%20Type%20Status%20Summary%20Modified%20Owner%20Mstone%20OS

看一下规范,这确实看起来像一个错误:
http://www.w3.org/TR/css3-background/ #box-shadow-samples

这些示例也有带 alpha 的内边框,并显示类似 Firefox 的行为。

Bug on the Chrome issues list (guess what, nobody cares):
http://code.google.com/p/chromium/issues/detail?id=36475&q=transparent%20border%20color&colspec=ID%20Stars%20Pri%20Area%20Feature%20Type%20Status%20Summary%20Modified%20Owner%20Mstone%20OS

Taking a look at the spec, this indeed seems like a bug:
http://www.w3.org/TR/css3-background/#box-shadow-samples

The examples, too, have an inner border with alpha and show Firefox like behavior.

Hello爱情风 2024-10-16 04:42:25

您遇到的问题在这里详细讨论:

http://snook.ca/archives/html_and_css /safari-transparent-borders

如果你稍微改变碰撞边框的不透明度值,你会得到一个不完美的修复,希望有帮助。

The problem you have is discussed in detail here:

http://snook.ca/archives/html_and_css/safari-transparent-borders

If you change the opacity value of the colliding borders just a tiny bit you get a non-perfect fix, hope that helps.

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