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;
}
相关推荐
潍坊老登16 小时前
关于 number类型从vue端传到golang后端是float而不是int的事
前端
茶底世界之下16 小时前
你的 Mac 里,藏着一支 AI 开发团队
前端·javascript
小白学大数据17 小时前
Playwright 爬虫:Python 爬取 JS 渲染的 JSP 网站
开发语言·javascript·爬虫·python·数据分析
不爱说话郭德纲17 小时前
出门在外收到任务,我用 TRAE SOLO 把电脑“叫醒”干活
前端·ai编程
前端Hardy17 小时前
这个前端动画库,火了!
前端·javascript
小林攻城狮17 小时前
Vite项目使用@turbodocx/html-to-docx报错问题排查与解决方案
前端·ai编程
Asmewill17 小时前
LangGraph学习笔记六(Stream流式输出)
前端
哈撒Ki17 小时前
前端性能优化汇总
前端·面试
Asmewill17 小时前
LangGraph学习笔记七(checkpointer)
前端
前端小木屋17 小时前
uniapp与蓝牙设备连接详细步骤
前端·微信小程序