Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

css四个角边框效果

作者:网络神话—爷恋   发布日期:2026-08-05   浏览:7

/* 定义一个带有四个角边框效果的盒子 */
.box {
  width: 200px;
  height: 100px;
  background-color: #f0f0f0;
  position: relative;
}

/* 左上角 */
.box::before {
  content: '';
  position: absolute;
  top: -10px;
  left: -10px;
  border-top: 10px solid black;
  border-left: 10px solid black;
  width: 0;
  height: 0;
}

/* 右上角 */
.box::after {
  content: '';
  position: absolute;
  top: -10px;
  right: -10px;
  border-top: 10px solid black;
  border-right: 10px solid black;
  width: 0;
  height: 0;
}

/* 左下角 */
.box .corner-bottom-left {
  content: '';
  position: absolute;
  bottom: -10px;
  left: -10px;
  border-bottom: 10px solid black;
  border-left: 10px solid black;
  width: 0;
  height: 0;
}

/* 右下角 */
.box .corner-bottom-right {
  content: '';
  position: absolute;
  bottom: -10px;
  right: -10px;
  border-bottom: 10px solid black;
  border-right: 10px solid black;
  width: 0;
  height: 0;
}

解释说明:

  • .box 是主容器,设置了宽度、高度和背景颜色。
  • 使用 ::before::after 伪元素来创建左上角和右上角的边框效果。
  • 对于左下角和右下角,使用了额外的子元素 .corner-bottom-left.corner-bottom-right 来实现边框效果。
  • 每个角的边框是通过设置 border 属性并结合 widthheight 为 0 来创建三角形的效果。

上一篇:css 不允许选中

下一篇:文字渐变css

大家都在看

css好看的字体

css 红色

css 瀑布流布局grid

css盒子

css字体加粗怎么设置的

css三种引入方式

换行 css

css设置文字不换行

css文字超长省略号

css图片铺满整个背景

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站