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;
		}
	}
}
相关推荐
唐小码5 分钟前
裁员的风刮到了三线荒凉的城市
前端
晚安日记wanna17 分钟前
React 为何不做双端 diff?Vue 与 React 更新逻辑的三层差异
前端·react.js·面试
flash俊杰20 分钟前
AI 分段引擎与自动剪辑决策:从语义片段到时间线草稿的映射
前端·ai编程
flash俊杰32 分钟前
时间线交互引擎:从像素到帧的逆向映射与磁吸网格
前端
光影少年32 分钟前
setImmediate 和 setTimeout(0) 的区别
android·前端·react.js·ios·前端框架
flash俊杰35 分钟前
LLM 结构化输出的契约化工程:JSON Mode、Schema 约束与重试降级
前端·ai编程
༄久梦༒长醉༻36 分钟前
AI面试助手:本地运行,一键备战
前端·ai编程
Web4Browser39 分钟前
浏览器指纹逆向到底在分析什么:从 JavaScript 采集、Canvas 与 WebGL 到环境一致性校验
java·服务器·前端
2601_9583529040 分钟前
不改PCB也能调拾音方向?真相在这。
前端·嵌入式硬件·回声消除·语音模块·降噪处理
zhanghaha13141 小时前
HTML系列教程:17_HTML 框架(frameset、frame、iframe)零基础详解
前端·html