边框不透明?
How would you do borders with opacity in CSS? RGBA
colors aren't working for me...
A JSFiddle is self explaining.
There are dark corners in the border, and the background of the element is visible behind it instead of the other elements behind it.
Thank You.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能有更好的方法,但这可行:
现场演示
基本上,只需使用包装器
div
并将rgba
设置为背景即可。HTML:
CSS:
阅读此答案的注释,了解如何使此方法 (
rgba
) 在旧版浏览器中工作。一种不使用包装器的方法:
使用
outline
而不是border
,它看起来可以接受:现场演示(这是您的确切代码,更改了一个单词)
(我在这里丝毫不考虑 IE)
查看这篇文章:
http://css-tricks.com/transparent-borders-with-background-clip/
There might be a better way, but this works:
Live Demo
Basically, just use a wrapper
div
with thergba
set as a background.HTML:
CSS:
Read the comments to this answer to see how to make this method (
rgba
) work with older browsers.A way to do it without using a wrapper:
Use
outline
instead ofborder
, it looks acceptable:Live Demo (it's your exact code, with the one word changed)
(I'm not considering IE here in the slightest)
Check out this article:
http://css-tricks.com/transparent-borders-with-background-clip/
我认为第一个答案是最好的,尽管您现在可以在边框中使用图像,尝试使用具有透明度的 png 图像(通过 Photoshop)使用 border-image 属性,有很多方法可以使用它,您可能会找到您喜欢的另一种样式研究。
http://www.css3.info/preview/border-image/
I think the 1st answer is the best though you can use images in borders now, try using a png image with transparency (via photoshop) use the border-image property, there's so many ways to use it you may find another style you prefer in the research.
http://www.css3.info/preview/border-image/