CSS realizes the speech bubble effect with sharp corners in the small sharp corner chat dialog box

CSS realizes the speech bubble effect with sharp corners in the small sharp corner chat dialog box

1. Use CSS to draw a small pointed-corner chat dialog box and a speech bubble with pointed corners. Let me show you the effect picture first. If you like it, please refer to the example code.

2. Effect

3. Code

css;toolbar:false"><style>
#talkbubble
  width: 160px; height: 80px;
  background: red;
  position: relative;
  border-radius: 10px;
  margin-left:20px;
}
#talkbubble:before {
  content: "";
  position: absolute;
  right: 100%; 
  top: 26px;
  border-top: 13px solid transparent;
  border-right: 26px solid red;
  border-bottom: 13px solid transparent;
}
</style>
<div id="talkbubble"></div>

Supplement: Pure CSS to achieve bubble dialog box sharp corner processing

Let’s take a look at the effect diagram first:

Simple and rough code:

html:

    <div class="dialog-box">
                      <span class="bot"></span>
                      <span class="top"></span>
                    </div>
less:
      .dialog-box {
        position: relative;
        span {
          width:0; 
          height:0; 
          font-size:0; 
          overflow:hidden; 
          position:absolute;
          &.bot{
            border-width: 15px; 
            border-style: solid dashed dashed; 
            border-color: transparent transparent #F9743A transparent; 
            left: 15px; 
            top: -29px;
          }
          &.top{
            border-width:13px; 
            border-style:solid dashed dashed; 
            border-color:transparent transparent #fff transparent; 
            left:17px; 
            top:-25px;
          }
        }
      }

Explanation in plain language:

If you want sharp corners in other directions, adjust the order of boder-color (top, right, bottom, left).

The main principle is probably to have two small triangles of the same shape but different proportions, a solid triangle bot with the same color as the background, and a top with a white background, and the top will cover the bot, and then adjust their sizes (generally speaking, the solid one should be larger than the white block, so that the edges can show the color).

Finally, I tried every possible way to make them overlap (white top on top, solid bot on the bottom), and finally adjusted the absolute positioning parameters (left, top) to make them overlap seamlessly. Okay, it’s done. Do you get it?

Summarize

This is the end of this article about how to use CSS to achieve a small pointed corner chat dialog box with a pointed speech bubble effect. For more relevant CSS pointed corner chat dialog box content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope that everyone will support 123WORDPRESS.COM in the future!

<<:  20 excellent foreign web page color matching cases sharing

>>:  Linux service monitoring and operation and maintenance

Recommend

Vue implements multi-tab component

To see the effect directly, a right-click menu ha...

How to monitor Linux server status

We deal with Linux servers every day, especially ...

Solve the problem of setting Chinese language pack for Docker container

If you use docker search centos in Docker Use doc...

Implement MySQL read-write separation and load balancing based on OneProxy

Introduction Part 1: Written at the beginning One...

Summary of common commands for Ubuntu servers

Most of the commands below need to be entered in ...

Analysis of JavaScript's event loop mechanism

Table of contents Preface: 1. Reasons for the eve...

CentOS7 uses rpm to install MySQL 5.7 tutorial diagram

1. Download 4 rpm packages mysql-community-client...

Build a WebRTC video chat in 5 minutes

In the previous article, I introduced the detaile...

How to view server hardware information in Linux

Hi, everyone; today is Double 12, have you done a...

Solution to 404 error when downloading apk file from IIS server

Recently, when using IIS as a server, the apk fil...

Implementation of mysql configuration SSL certificate login

Table of contents Preface 1. MySQL enables SSL co...

Super detailed basic JavaScript syntax rules

Table of contents 01 JavaScript (abbreviated as: ...