如何使用css制作边框三角形?

Jal*_*Jal 2 html css

如何创建边界三角形?

在此处输入图片说明

我唯一能想到的就是做一个三角形

    .triangle {
        width: 0; 
        height: 0; 
        border-left: 15px solid transparent;
        border-right: 15px solid transparent;
        border-bottom: 20px solid #8e8e8e;
    }
Run Code Online (Sandbox Code Playgroud)

但这是一个实心三角形,有没有办法让它看起来像三角形延伸边界

rob*_*t-s 5

创建一个绝对位于 div 底部的:afteror:before元素。

.box {
  position: relative;
  background-color: #F00;
  border: 1px solid #000;
  width: 50px;
  height: 50px;
}

.box:after {
  content: "";
  width: 16px;
  height: 16px;
  position: absolute;
  background-color: #FFF;
  bottom: -8px;  /* half of the elements width/height */
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  border-bottom: 1px solid #000;
  border-right: 1px solid #000;
}
Run Code Online (Sandbox Code Playgroud)
<div class="box">
Run Code Online (Sandbox Code Playgroud)

我已将:after元素设为白色,以便您可以看到其中发生了什么。