【发布时间】:2015-03-15 02:49:52
【问题描述】:
我正在使用 CSS 创建一个语音气泡,并且已经到了这一步。
.says{
width: 200px;
padding: 20px;
margin-right: 20px;
background: #BF7EF2;
color: #fff;
box-shadow: -3px 3px 5px #C1B9C8;
position: relative;
border-radius: 5px;
}
.says:before{
content: "";
position: absolute;
z-index: -1;
top: 14px;
right: -18px;
height: 20px;
border-right: 20px solid #BF7EF2;
border-bottom-right-radius: 25px 20px;
transform: translate(0, -4px);
box-shadow: -3px 3px 5px #C1B9C8;
}
.says:after{
content: "";
position: absolute;
z-index: -1;
top: 7px;
right: -18px;
width: 30px;
height: 30px;
background: #fff;
border-bottom-left-radius: 40px 35px;
transform: translate(0px, -20px);
}
<div class="says">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ratione aut facere cupiditate, sunt, nisi fugiat consectetur officiis veniam!</div>
基本上我已经使用了:before 和:after 伪类并应用了border-radius。然后相互重叠,达到想要的效果。现在你可以看到,我在:after 上使用background: #fff,因为当前父母的背景是白色的。这将在我的应用程序中遍历许多具有不同背景颜色的不同 div。这就是我现在遇到的问题。
示例-
我能否在不使用 :after 的背景属性的情况下实现相同的“语音气泡”尾部?
^ 这行说明它不是链接问题的重复。
或者通过其他完全不同的方式?
【问题讨论】:
-
@web-tiki 链接的问题有答案,他也在
:after上使用background属性,但这里不是这种情况。正如我在问题末尾所说的那样,我不想使用背景。这是一个不同的场景,我认为不是重复的。 -
@web-tiki 我之前已经实现了与 vals 相同的效果,但是我在这里使用的形状不同。尾巴的锋利边缘位于另一侧的中间某处。 TylerH 的那个不是弯曲的,而是一个直的三角形。
标签: css css-shapes