Home > Web Front-end > CSS Tutorial > Example code for realizing the sharp corner effect of bubble dialog box using pure CSS

Example code for realizing the sharp corner effect of bubble dialog box using pure CSS

零下一度
Release: 2017-06-29 15:58:43
Original
1599 people have browsed it

This article mainly introduces the implementation code of pure CSS to implement sharp corner processing of bubble dialog boxes. It is very good and has reference value. Friends who need it can refer to it

First, let’s take a look at the renderings:

Simple and crude code:
html:


<p class="dialog-box">  
  <span class="bot"></span>  
  <span class="top"></span>  
</p>
Copy after login

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;  
    }  
  }  
}
Copy after login

Vernacular explanation:

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

The main principle is probably to have two small triangles with the same shape but different proportions, a solid triangle bot with the same background color, and a top with a white background, and the top will cover the bot, and then Adjust their size (generally speaking, the solid ones are larger than the white ones, so that the winking edges can be shown).

Finally tried every means to make them overlap (the white top is on top, the solid bot is below), and finally made them overlap by adjusting the absolute positioning parameters (left, top) Seamless. Okay, you're done. I wonder if you got it?

The above is the detailed content of Example code for realizing the sharp corner effect of bubble dialog box using pure CSS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template