Webkit 中奇怪的边框不透明行为?
我一直在测试不透明的边框,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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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.
您遇到的问题在这里详细讨论:
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.