Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
385 views
in Technique[技术] by (71.8m points)

html - How to create a curved speech bubble?

I'm trying to make a curved speech bubble out of a div, like this:

enter image description here

This is what I've tried, but it doesn't really work:

.userMsgBottom{
  position: relative;
  display: inline-block;
  max-width: 260px;
  height: auto;
  word-wrap: break-word;
  background-color: #2e7384;
  margin-top: 12px;
  margin-left: 8px;
  margin-right: 8px;
  padding: 7px;
  border-radius: 6px;
}
.userMsgBottom:after {
    content: "";
    position: absolute;
    bottom: 0px;
    right: 5px;
    width: 70px;
    height: 30px;
    background-color: #2e7384;
    transform: skew(45deg);
    transform-origin: top right;
    border-radius: 0 15% 5% 0% / 25%;
    z-index: -1;
}

it does this:

enter image description here

How would I go about doing this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I would consider radial-gradient to do this:

.userMsgBottom {
  position: relative;
  display: inline-block;
  color:#fff;
  max-width: 260px;
  background-color: #2e7384;
  margin: 12px 8px 0;
  padding: 7px;
  border-radius: 6px;
}

.userMsgBottom:after {
  content: "";
  position: absolute;
  bottom: 0px;
  right: -23px;
  width: 30px;
  height: 25px;
  background: radial-gradient(circle at top right, transparent 58%, #2e7384 60%);
}
<div class="userMsgBottom">
  Some text here<br> Some text here<br> Some text here
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...