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;
		}
	}
}
相关推荐
二月龙1 分钟前
移动端 H5 页面开发:响应式适配 + 低版本兼容实战指南
前端
小强19884 分钟前
HTML5 新表单全解:日期、手机号、颜色选择器
前端
妙码生花6 分钟前
从 PHP 到 AI + Golang,程序员自救转型手记(二):目录结构、初始化 GIT、设计并开发配置系统
前端·后端·go
鱼人7 分钟前
HTML5 本地存储终极指南
前端
超绝大帅哥21 分钟前
React的Fiber是什么? Vue为什么不需要Fiber ?
前端
yingyima27 分钟前
正则表达式分组与捕获:凌晨3点服务器报警的解决方案
前端
swipe1 小时前
从 0 到 1 理解 React 虚拟列表:定高、不定高与 Canvas 版本完整拆解
前端·javascript·面试
铁皮饭盒2 小时前
Bun执行python代码
前端·javascript·后端
hunterandroid2 小时前
Service 与前台服务:让任务在后台持续运行
前端
米饭同学i2 小时前
深扒 LobsterAI 官网前端动效实现方案:从交互细节到代码实践
前端