我发现对标题文本做了this样式,我认为这是一个贯穿文本的双边框,但不与文本重叠。有谁知道如何对我的h1元素执行相同操作?

最佳答案

快速而肮脏的解决方案:



    h1 {
      position: relative;
      text-align: center;
     }
    h1:before {
      content: " ";
      position: absolute;
      height: 6px;
      width: 40%;
      border-top: 1px solid black;
      border-bottom: 1px solid black;
      left: 0;
      top: 40%;
    }
    h1:after {
      content: " ";
      position: absolute;
      height: 6px;
      width: 40%;
      border-top: 1px solid black;
      border-bottom: 1px solid black;
      right: 0;
      top: 40%;
    }

    <h1>Title</h1>

10-05 21:01
查看更多