CSS实现半边边框(只有边框的部分可见)

CSS实现半边边框(只有边框的部分可见)

html 复制代码
<div class="part box">
	<h1>内容</h1>
	<!-- 绘出下面两个对角边框-->
	<div class="part-footer"></div>
</div>
  • 主要代码
css 复制代码
.box {
	width: 100px;
	height: 100px;
}
.part {
	position: relative;
	&::before {
		position: absolute;
		top: 0;
		left: 0;
		content: '';
		width: 20px;
		height: 20px;
		border-left: 4px solid #4381ad;
		border-top: 4px solid #4381ad;
	}
	&::after {
		position: absolute;
		top: 0;
		right: 0;
		content: '';
		width: 20px;
		height: 20px;
		border-right: 4px solid #4381ad;
		border-top: 4px solid #4381ad;
	}
	.part-footer {
		position: absolute;
		bottom: 0;
		left: 0;
		width: 100%;
		&::before {
			position: absolute;
			bottom: 0;
			left: 0;
			content: '';
			width: 20px;
			height: 20px;
			border-left: 4px solid #4381ad;
			border-bottom: 4px solid #4381ad;
		}
		&::after {
			position: absolute;
			right: 0;
			bottom: 0;
			content: '';
			width: 20px;
			height: 20px;
			border-right: 4px solid #4381ad;
			border-bottom: 4px solid #4381ad;
		}
	}
}
相关推荐
懂懂tty2 小时前
CRA 迁移 Rspack(实战)
前端·架构
小码哥_常3 小时前
Kotlin 助力 Android 启动“大提速”
前端
GreenTea4 小时前
AI 时代,工程师的不可替代性在哪里
前端·人工智能·后端
Jagger_4 小时前
能不能别再弄低代码害人了
前端
朦胧之4 小时前
AI 编程开发思维
前端·后端·ai编程
踩着两条虫5 小时前
VTJ:快速开始
前端·低代码·架构
木斯佳6 小时前
前端八股文面经大全:携程前端一面(2026-04-17)·面经深度解析
前端·状态模式
Java后端的Ai之路6 小时前
LangChain ReAct Agent 核心技术问答
前端·react.js·langchain
码喽7号6 小时前
Vue学习七:MockJs前端数据模拟
前端·vue.js·学习
NotFound4867 小时前
探究分享从对话到执行:OpenTiny NEXT 如何重塑前端智能化开发范式
前端