设计边框底部

问题描述 投票:0回答:2

我想设计一个如下图所示的边框。但我对如何做到这一点的想法已经不多了。 enter image description here

https://codepen.io/szn0007/pen/VRGPyE

div.about-me h2{
  color: #000;
  border-bottom: 1px solid #efefef;
  width: 20%;
  margin: 0 auto;
  padding: 20px;
}

先感谢您。

html css
2个回答
3
投票

幸运的是,你可以在每个容器上访问两个pseudo elements。我将Asterix添加到其中一个伪元素:after,将该行添加到另一个:before

例如:

.fancy-underline {
  position: relative;
  display: inline-block;
}

.fancy-underline:before {
  content: '';
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 100%;
  height: 1px;
  background: grey;
}

.fancy-underline:after {
  content: '*';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
}
<h2 class="fancy-underline">About Me</h2>

1
投票

试试这个:

           <div class="about-me">
           <h2>About Me</h2>
           <p>*</p>
           </div>

CSS:

          div.about-me{
           width: 100%;
          text-align: center;
          }

          div.about-me h2{
          color: #000;
          border-bottom: 1px solid #efefef;
          width: 20%;
          margin: 0 auto;
          padding: 20px;
          }

         p {
         font-size: 50px;

         transform: translatey(-72px);

         }
© www.soinside.com 2019 - 2024. All rights reserved.