使 div 透明但保持边框可见
我有一个气泡形状的 div。这是代码:
<div class="dragThis" id="dragThis">
<div class="content" id="content">
<p>
<asp:Label ID="lblContent" runat="server" Text="Label"></asp:Label>
</p>
</div>
<div class="pointer">
<div class="one">
</div>
<div class="two">
</div>
</div>
</div>
这是 css:
<style type="text/css">
.dragThis
{
width: 400px;
color: #efefef;
position: absolute;
}
.pointer
{
-moz-opacity: 0.5;
-khtml-opacity: 0.5;
filter: alpha(opacity=50);
height: 560px;
}
.dragThis .pointer
{
height: 35px;
background: #393939;
}
.dragThis .pointer div
{
height: 100%;
background: #ffffff;
}
.dragThis .pointer .one
{
width: 50%;
-moz-border-radius-topright: 35px;
-webkit-border-top-right-radius: 35px;
float: left;
}
.dragThis .pointer .two
{
width: 50%;
float: right;
-moz-border-radius-topleft: 35px;
-webkit-border-top-left-radius: 35px;
}
.dragThis .content
{
padding: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
background: #393939;
text-align: center;
}
</style>
这里的问题如您所见,气泡的下部是 %50 可见。我希望黑色部分 %100 可见,而其他部分都是透明的。
谢谢。
I have a div in a shape of speech bubble. Here is the code:
<div class="dragThis" id="dragThis">
<div class="content" id="content">
<p>
<asp:Label ID="lblContent" runat="server" Text="Label"></asp:Label>
</p>
</div>
<div class="pointer">
<div class="one">
</div>
<div class="two">
</div>
</div>
</div>
Here is the css:
<style type="text/css">
.dragThis
{
width: 400px;
color: #efefef;
position: absolute;
}
.pointer
{
-moz-opacity: 0.5;
-khtml-opacity: 0.5;
filter: alpha(opacity=50);
height: 560px;
}
.dragThis .pointer
{
height: 35px;
background: #393939;
}
.dragThis .pointer div
{
height: 100%;
background: #ffffff;
}
.dragThis .pointer .one
{
width: 50%;
-moz-border-radius-topright: 35px;
-webkit-border-top-right-radius: 35px;
float: left;
}
.dragThis .pointer .two
{
width: 50%;
float: right;
-moz-border-radius-topleft: 35px;
-webkit-border-top-left-radius: 35px;
}
.dragThis .content
{
padding: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
background: #393939;
text-align: center;
}
</style>
The problem here is as you can see, the lower part of the speech bubble is %50 visible. I want the black part to be %100 visible and every other part to be transparent.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一个有效的例子会很好。
您无法将不透明度分成不同的部分。但是,如果您的元素没有背景,则除了边框之外,它将是透明的。
A working example would be nice.
You cannot seperate the opacity into different parts. But if your element doesn't have a background, it will be transparent, except for the borders.
您可以使用最后一个值为 0 的 rgba 颜色来代替不透明度,例如 rgba(255,255,255,0)。就我而言,不透明度是继承的,但 rgba 值不是。
Instead of opacity you could use rgba colours with the last value as 0, for example rgba(255,255,255,0). As far as I'm concerned, opacity is inherited, but the rgba values are not.