gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 12:33:38 24 4
gpt4 key购买 nike

我正在用 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 因为当前父对象的背景是白色的。这将在我的应用程序中遍历许多具有不同 bg 颜色的不同 div。这就是我现在遇到的问题。

示例-
enter image description here

我能否在不使用 :after 的背景属性的情况下实现相同的“语音气泡”尾部?
^ 此行说明它不是链接问题的副本。

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

最佳答案

正如 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">

关于css - 如何使用 CSS 为语音气泡创建曲线尾部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29051539/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com