css - 完全透明的边框

标签 css border transparency

简单问题

目标:使边框(左和右)完全透明,以便可以看到主体背景颜色。

尝试:http://jsfiddle.net/ZRQmY/

<html>
<body>
<div id="wrap">
<div class="trap">
    Make the white borders transparent, so when I change the background color the background color will be seen through the borders.
    I've tried rgb() with opacity but no luck
</div>
<div class="trap2">
   This is what I'd like but I'm setting the border = bg color;
</div>

</div>
</body>
</html>

CSS

body {background:#eee;}
#wrap {padding:50px;}
.trap {
width:350px;
background: rgb(238, 238, 238);
border-right: 30px solid transparent;
border-left: 30px solid transparent;
border-bottom: 30px solid rgb(216, 199, 143);
}
.trap2 {
width:350px;
margin-top:100px;
background: rgb(238, 238, 238);
border-right: 30px solid #fff;
border-left: 30px solid #fff;
border-bottom: 30px solid rgb(216, 199, 143);
}

我已经尝试了很多解决方法,但对我的具体问题无济于事。

你的包里还有什么花样吗?

最佳答案

哈..在点击提交前几秒钟找到了答案。

确保将要透明的元素的背景设置为:background:none; 或什么都不设置。

编辑:感谢 David Thomas

如果不这样做,边框将(完全)透明。但是边框实际上是“绘制在”元素的背景颜色上的;这样背景颜色就可以“通过”透明边框看到。

关于css - 完全透明的边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14864637/

相关文章:

html - 覆盖边界而不移动它

wpf - 在 WPF 中使用另一个控件作为不透明蒙版?

html - 如何让一个label的内容在落到下一行的时候留在父元素下面?

javascript - 使用 Javascript 将图像叠加在图像上

html - 带有图标的按钮上的倒椭圆边框

javascript - 如何在div中对齐文本和图像垂直居中

css - 控制虚线边框笔划长度和笔划间距

html - 背景 (a) 和边框 (ul) 之间的白色间隙

css - Cufon 弄乱了我的透明 PNG 背景

java - 无法在android中设置背景完全透明