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;
}
相关推荐
IT乐手13 小时前
佛德角逼平西班牙,国足还有啥借口?
前端
JustHappy13 小时前
我汇总了身边朋友的经历才发现,其实第一份实习是最难找的......
前端·后端·面试
星栈13 小时前
Dioxus 的响应式系统:`Signal`、`Memo`、`Effect` 和异步状态到底该怎么分工
前端·前端框架
yingyima13 小时前
Java 正则表达式:比你想象的更强大
前端
yuanyxh16 小时前
macOS 应用 - 纯对话生成
前端·macos·ai编程
大家的林语冰16 小时前
ES5 凉凉,Babel 8 正式发布,默认不再编译为 ES5 和 CJS......
前端·javascript·前端工程化
光影少年18 小时前
react批量更新、同步/异步更新场景
前端·react.js·掘金·金石计划
假如让我当三天老蒯18 小时前
模块化:ES Module 与 CommonJS 的区别
前端·面试
用户409501157731718 小时前
Private Forge v2.0 发布:12大前端业务场景技能系统
前端
weedsfly19 小时前
异步编程全景与事件循环——彻底搞懂 JS 执行机制
前端·javascript