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;
}
相关推荐
小小小小宇5 分钟前
前端一文搞懂webpack loader
前端
小小小小宇12 分钟前
一文搞懂webpack插件
前端
小小小小宇19 分钟前
一文搞定ESlint插件
前端
!chen28 分钟前
基于element-UI 实现下拉框滚动翻页查询通用组件
javascript·vue.js·ui
seraph99942 分钟前
pyecharts 画一下股票的月K图(输出html)
前端·python·html
sorryhc2 小时前
钉钉红包性能优化之路
前端·javascript·性能优化
袁煦丞2 小时前
你的在线相册管理专家Piwigo:cpolar内网穿透实验室第487个成功挑战
前端·程序员·远程工作
꧁༺摩༒西༻꧂2 小时前
Python生成日历导出Excel
java·前端·python
Mintopia3 小时前
计算机图形学的奇幻之旅:第三天探索
前端·javascript·计算机图形学
Mintopia3 小时前
Three.js 物理材质:打造 3D 世界的 “魔法皮肤”
前端·javascript·three.js