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;
		}
	}
}
相关推荐
JinSo8 分钟前
我的2025年度总结:EasyEditor
前端·程序员
喝拿铁写前端4 小时前
前端开发者使用 AI 的能力层级——从表面使用到工程化能力的真正分水岭
前端·人工智能·程序员
wuhen_n5 小时前
LeetCode -- 15. 三数之和(中等)
前端·javascript·算法·leetcode
七月shi人5 小时前
AI浪潮下,前端路在何方
前端·人工智能·ai编程
非凡ghost5 小时前
MusicPlayer2(本地音乐播放器)
前端·windows·学习·软件需求
脾气有点小暴5 小时前
scroll-view分页加载
前端·javascript·uni-app
beckyye6 小时前
ant design vue Table根据数据合并单元格
前端·antd
布列瑟农的星空6 小时前
还在手动翻译国际化词条?AST解析+AI翻译实现一键替换
前端·后端·ai编程
土豆12506 小时前
Rust 错误处理完全指南:从入门到精通
前端·rust·编程语言