【发布时间】:2021-01-15 22:50:06
【问题描述】:
【问题讨论】:
-
从像素化来看,这可能只是一张图片。但是您可以使用
border-radius实现类似的效果。请尝试一下,如果遇到困难,请发布您的代码。
标签: html css css-shapes
【问题讨论】:
border-radius 实现类似的效果。请尝试一下,如果遇到困难,请发布您的代码。
标签: html css css-shapes
您可以使用带有透明圆圈的radial-gradient 来创建对话气泡的弯曲尖端。将其应用于气泡的 ::before 伪元素,使其放置在您的对话气泡 div 的顶部。
.bubble::before {
content: '';
height: 30px;
width: 30px;
background: radial-gradient(circle at 100% 0, transparent 30px, cornflowerblue 0);
display: block;
margin-left: 100px;
}
.message {
padding: 10px 20px;
width: 300px;
background: cornflowerblue;
display: block;
font-family: sans-serif;
color: floralwhite;
font-size: 18px;
border-radius: 0 0 10px 10px;
}
<div class="bubble">
<div class="message">
<p>"Tell me and I forget. Teach me and I remember. Involve me and I learn."<p>
<small>Benjamin Franklin</small>
</div>
</div>
您可以将::after 伪元素与z-index 结合使用,以在将鼠标悬停在对话气泡上时创建边框效果。
.bubble::before,
.bubble::after {
content: '';
display: block;
position: absolute;
}
.bubble::before {
background: radial-gradient(circle at 95% -2px, transparent 25px, cornflowerblue 0);
left: 103px;
top: 10px;
z-index: 1;
height: 25px;
width: 25px;
}
.bubble::after {
background: radial-gradient(circle at 100% 0, transparent 30px, coral 0);
left: 100px;
top: 0px;
z-index: -1;
height: 30px;
width: 30px;
display: none;
}
.message {
padding: 10px 20px;
width: 300px;
background: cornflowerblue;
display: block;
font-family: sans-serif;
color: floralwhite;
font-size: 18px;
border-radius: 0 0 10px 10px;
border: 3px solid white;
margin-top: 30px;
}
.bubble:hover > .message {
border: 3px solid coral;
}
.bubble:hover::after {
display: block;
}
<div class="bubble">
<div class="message">
<p>"Tell me and I forget. Teach me and I remember. Involve me and I learn."<p>
<small>Benjamin Franklin</small>
</div>
</div>
【讨论】: