Linear gradient generates bubble zone triangle

.talk {
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 6px 10px;
    font-size: 14px;
    background-color: #fff;
    position: relative;
}
.talk::before {
    content: ' ';
    position: absolute;
    width: 6px; height: 6px;
    background: linear-gradient(to top, #ddd.#ddd) no-repeat, linear-gradient(to right, #ddd.#ddd) no-repeat, linear-gradient(135deg.#fff.#fff 6px.hsla(0.0%.100%.0) 6px) no-repeat;
    background-size: 6px 1px.1px 6px.6px 6px;
    transform: rotate(-45deg);
    left: -4px; top: 13px;
}
Copy the code

Border-color implements the triangle

@mixin triangle($width.$height.$color.$direction) {
  $width: $width/2;
  $color-border-style: $height solid $color;
  $transparent-border-style: $width solid transparent;
  height: 0;
  width: 0;

  @if $direction==up {
    / / <! -- Only the bottom border is colored, the rest is transparent -->
    border-bottom: $color-border-style;
    border-left: $transparent-border-style;
    border-right: $transparent-border-style;
  }

  @else if $direction==right {
    border-left: $color-border-style;
    border-top: $transparent-border-style;
    border-bottom: $transparent-border-style;
  }

  @else if $direction==down {
    border-top: $color-border-style;
    border-left: $transparent-border-style;
    border-right: $transparent-border-style;
  }

  @else if $direction==left {
    border-right: $color-border-style;
    border-top: $transparent-border-style;
    border-bottom: $transparent-border-style; }}Copy the code

The CLIp-path property of CSS3 implements triangulation

.triangle{
    width: 10px;
    height: 10px;
    background: red;
    / * <! Join coordinates (0,0), (5,10), (10,0) into a triangle --> */
    clip-path: polygon(0px 0px.5px 10px.10px 0px);
    / * <! -- Rotate 180° to lower triangle --> */
    transform: rotate(180deg);
}
Copy the code