html - 如何使用CSS制作边框三 Angular 形?

标签 html css

如何创建边框三 Angular 形?

enter image description here

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

    .triangle {
        width: 0; 
        height: 0; 
        border-left: 15px solid transparent;
        border-right: 15px solid transparent;
        border-bottom: 20px solid #8e8e8e;
    }

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

最佳答案

创建一个绝对位于 div 底部的 :after: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;
}
<div class="box">

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

关于html - 如何使用CSS制作边框三 Angular 形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47318399/

相关文章:

html - django html/css windows mac 问题 width 页面顶部额外空间

html - 将包含动态调整大小的输入元素的内联标签定位到表单中

javascript - 如何根据值为 HTML 表格单元格着色

html - CSS : Overwriting using style tag on JSP page

html - 下拉菜单未出现

javascript - div滚动时如何调整宽度?

html - 如何在 inline-block 上留边距我想移动整个进度条?

javascript - 这个错误 "Uncaught TypeError: Cannot read property ' style' of undefined” 是什么意思?

html - 在手机上查看网站时,页脚的背景被截断

html - 背景图像上的图像闪烁