如何使用CSS为语音气泡创建曲线尾部?

时间:2015-03-14 16:49:37

标签: css css3 css-shapes

我用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>
&#13;
&#13;
&#13;

基本上我使用了:before:after伪类并应用了border-radius。然后相互重叠以达到欲望效果。现在你可以看到,我在background: #fff上使用:after,因为当前父母的背景是白色的。这将遍及我的应用程序中不同的bg颜色的许多不同的div。这就是我现在遇到的问题。

示例 -
enter image description here

我可以实现相同的#34;语音泡沫&#34;尾部没有使用:after上的背景属性? ^此行说明它不是链接问题的副本。

或者通过其他完全不同的方式?

1 个答案:

答案 0 :(得分:5)

正如webtiki所说,你可以得到这个结果以适应我以前的答案(即使可能有点困难)

.container {
  width:300px;
  margin:5px;
}
.test 
{
position: relative;
width: 300px;
height: 150px;
padding: 0px;
background: pink;
border-radius: 6px;
}

.test:after {
    content: '';
    top: 1px;
    right: -29px;
    position: absolute;
    border: 0px solid;
    display: block;
    width: 38px;
     height: 26px;
    background-color: transparent;
    border-bottom-left-radius: 50%;
    border-bottom-right-radius: 50%;
    box-shadow: -21px 9px 0px 8px pink;
}
<div class="container">
  <div class="test"></div>
</div>
<img src="http://i.stack.imgur.com/MYlKY.png" alt="enter image description here">