html 给文本两端加虚线自适应

效果图:

复制代码
<div class="separator">
    文本
</div>

.separator {
  width: 40%;
  border-style: dashed;
  display: flex;
  align-items: center;
  color: #e2e2e2;
  font-size: 14px;
  line-height: 20px;
  border-color: #e2e2e2;
  border-width: 0;
}

.separator::before {
  content: '';
  flex: 1;
  box-sizing: border-box;
  height: 1px;
  border-color: inherit;
  border-style: inherit;
  border-width: 2px 0 0;
  margin-right: 5px;
  padding: 0;
  outline: none;
}

.separator::after {
  content: '';
  flex: 1;
  box-sizing: border-box;
  height: 1px;
  border-color: inherit;
  border-style: inherit;
  border-width: 2px 0 0;
  margin-left: 5px;
  padding: 0;
  outline: none;
}
相关推荐
养老不躺平1 分钟前
关于nest项目打包
前端·javascript
fdc20176 分钟前
Avalonia:使用附加属性实现命令与事件的绑定
javascript·windows·microsoft
Mike_jia1 小时前
uuWAF:开源Web应用防火墙新标杆——从工业级防护到智能防御实战解析
前端
掘金安东尼1 小时前
Chrome 17 岁了——我们的浏览器简史
前端·javascript·github
袁煦丞1 小时前
群晖NAS FTP远程文件仓库全球访问:cpolar内网穿透实验室第524个成功挑战
前端·程序员·远程工作
前端小巷子1 小时前
JS 打造动态表格
前端·javascript·面试
excel1 小时前
从卷积到全连接:用示例理解 CNN 的分层
前端
UNbuff_01 小时前
HTML 各种事件的使用说明书
前端·html
Mr. Cao code1 小时前
探索OpenResty:高性能Web开发利器
linux·运维·服务器·前端·nginx·ubuntu·openresty
li35749 小时前
将已有 Vue 项目通过 Electron 打包为桌面客户端的完整步骤
前端·vue.js·electron